Home > Net >  Put a window winfrom multitasking
Put a window winfrom multitasking

Time:11-13

Recently when the program is written to the window to layout, winform window to minimize, maximize, close button and area to remove all logo, namely FormBorderStyle=None,
A problem, but this kind of treatment is window drag and drop, such as window resize winform can not use the built-in function (of course, has been through WndProc done afresh)
But one of the most important thing is lost, it is when we pull the window to the left to the right or to the top, when the mouse pointer abutting on the edge of the screen, automatic abutting edges without!
As shown in figure:


Online for a long time also didn't find a solution, and know?

CodePudding user response:

We don't know the way you code

But I think you need
 private const int WM_NCLBUTTONDOWN=0 xa1; 
Private const int HTCAPTION=2;



Private void Form1_MouseDown (object sender, System. Windows, Forms the MouseEventArgs e)
{

ReleaseCapture ();

SendMessage ((int). This Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0).
}



This code is to simulate forward a simulation of the moving window title message

Ps: again, if you copy the code from the blog garden, pay attention to distinguish the timeliness and effectiveness, and the people who write articles is not consider hell hole or pit

CodePudding user response:

Or alternative design, mobile set back to Sizable, mobile end in set none

CodePudding user response:

Another problem is that, winform events will not bubble, so there are other controls on the UI, event trigger won't be in the form, need to deal with

CodePudding user response:

You don't know what I mean, I mean the window close leaning, effect after close leaning is

CodePudding user response:

I see what you mean,

Because the alignment function depends on the form of a Sizable window attributes, so the first set to Sizable, let him change, in modified forms size form size, then back to none

This is the default dependence, dock alignment -- -- -- -- -- -- -- -- -- -- -- -- -- -- need to form sylte is variable, set to none, fixXXX are immutable style

CodePudding user response:

Studied win32api SDK all know

Form the actual style are controlled by WNDCLASS and WS_

https://blog.csdn.net/jadeshu/article/details/70477539? Utm_medium=distribute. Pc_relevant. None - task - blog - the title - 2 & amp; SPM=1001.2101.3001.4242

Can decide from win10 basic characterization, he should not system API support, but from the shell extension, handler, determine handler to the form style, when WS_SIZEBOX such set will response

We test the result: fixedsingle fixed3dDialog, this class specifies the "fixed" style was not alignment effects

CodePudding user response:

So I mean is there any way to let the window is the mouse to the edge of time, and have the same effect as a handler, you like QQ it is redrawing the window, you pull the QQ chat window to edge it can do it automatically stop half of the screen, and the dock is not uniquely win10, but since Windows 7 even small versions of Windows 7 before have the

CodePudding user response:

I tested another thing "youdao dictionary", it's clear that he is not a take the title, he's just custom painting, but his border is variable size, so he can dock alignment

Use spy + see style look at the form of style Settings, and then we can use win32api forced to modify your sytle style

CodePudding user response:

You don't need to emphasis on qq, Windows 7.

Can we just tell according to, the somebody else,

Because somebody else set is a border style, you are said a qq chat window, so you don't think he can widen? He can widen,

After you set none, you can widen the not? Don't set to FixedXXXX, can widen?? Can't

Reason spy++ told you, the somebody else with the style of the active set for win32:
WS_THICKFRAME -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- to create a window with a thick frame that can change the window size by thick border,
WS_EX_WINDOWEDGE -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- specifies the has raised frame window

This you can also use win32api

Set your own setWindowlong method

CodePudding user response:

In a 360 experiment, obviously 360 without borders is widening

You see the 360 can also use your this alignment function? The result is not aligned

CodePudding user response:

can you give specific code, I am not rich theoretical knowledge

CodePudding user response:

The first step is to find win32api function prototype and parameter Settings
https://blog.csdn.net/jigetage/article/details/85207073

The second step directly to pinvoke.org search win32api definition (Windows API standard win32api and common library this station has included)

http://www.pinvoke.net/default.aspx/user32/SetWindowLong.html

CodePudding user response:

Do STH over and over again, if the project manager asked me to do and turned on the spot,

CodePudding user response:

@ wanghui0380
Well, I'm not quite understand, you said I only need a post code directly

CodePudding user response:

Solve the problem maybe is very simple, but such as I never learn more or daily writing code that it does not contact the win32api, windos handle or what the news, for me is a bit deep, post code to my advantage is that, next time I meet the same problem, just copy and paste, don't have to understand its meaning

CodePudding user response:

reference 15 floor zhangleishiyan response:
solve this problem may be very simple, but such as I never learn more or daily writing code does not contact the win32api, windos handle or what the news, for me is a bit deep, post code to my advantage is that, next time I meet the same problem, just copy and paste, don't have to understand its meaning


Useless, you said, take the good with the world all can not find, so look at how we analysis problem, learn to how to solve the problem by themselves,
Next time you run into problems, perhaps is the world can't find, that I do

So, before you this problem, then put those things look at bai

Ps: it's been a long time I don't want to see a regular expression, I think it is the human language, so every time the Internet, but when I often need to use a project, and answers are nothing to spend 2 days to see regular, now I haven't asked others to regular almost 10 years

CodePudding user response:

Refer to WPF DragMove method implementation:
 
UnsafeNativeMethods. SendMessage (CriticalHandle, WindowMessage WM_SYSCOMMAND, (IntPtr) NativeMethods. SC_MOUSEMOVE, IntPtr. Zero).
UnsafeNativeMethods. SendMessage (CriticalHandle, WindowMessage WM_LBUTTONUP, IntPtr. Zero, IntPtr. Zero).

  •  Tags:  
  • C#
  • Related