Reputation: 35
I used to be able to do this more smoothly in XP but Windows 10 seems to have made it harder. In Windows 10 I can drag the right edge to resize the window with the following code for example:
SendMessage(f.Handle, WM_NCLBUTTONDOWN, HTRIGHT, 0)
The resizing is smooth and in real time. Any controls that are right-anchored move smoothly with the right edge.
That's great but in order to get rid of the window's border, I have to turn off WS_SIZEBOX (same as WS_THICKFRAME) with code such as this:
SetWindowLong(me.Handle, GWL_STYLE, GetWindowLong(me.Handle, GWL_STYLE) And Not WS_BORDER And Not WS_SIZEBOX And Not WS_DLGFRAME)
SetWindowPos(me.Handle, HWND_TOP, me.Left, me.Top, me.Width, me.Height, SWP_FRAMECHANGED)
Unfortunately turning off WS_SIZEBOX seems to deactivate drag resizing and causes the SendMessage/WM_NCLBUTTONDOWN code stop working.
Rolling My Own? I can of course write my own resizing routines by capturing mouse events and manipulating the location and size of the window. But this causes ugly black areas to appear while the borders are being dragged:
I assume this is because the form cannot repaint itself quickly enough during resizing. Anchored controls also do not move with the edge being dragged.
Can anyone point me toward a solution? For the sake of smoothness, I would like to use windows 10 native resizing routines if possible. Is there a way to somehow get around the state of WS_SIZEBOX and access the native routines more directly, or at a lower level?
I should add that I would like the entire form to be available to situate controls on so I don't want a TitleBar either, even if it's the very thin one that shows up when WS_SIZEBOX is on. Thanks
Upvotes: 0
Views: 357