How can I disable the snap feature of Windows 7 for my application (progmatically)? Or is there any way to detect if the application has been snapped, and specifically call an API function to unsnap it?
Calling SetWindowPos() or ShowWindow() does not unsnap it correctly *(SW_MAXIMIZE does). Calling SetWindowPos() actually causes strange behavior in future calls to SetWindowPos() and MoveWindow(). The same inconsistencies do not apply to a window that is maximized.
The PostMessage will be processed in subsequent message loop - it means ASAP after entering into move-size loop. If you use own drawing method of frame, please do not forget to redraw your frame correctly on
WM_STYLECHANGED
message, internally store oldStyle in your class. Why it works? Windows check snap condition at start of move/size action. IfWS_MAXIMIZE
andWS_MAXIMIZEBOX
are disabled at start, the snap behaviour is disabled.The
SC_SIZE|9
is equivalent ofSC_MOVE|2
without blocking redrawing for half a second.If you don't want to enable dragging maximized windows if they are fully maximized, check state of SC_MOVE item in system menu and if it is enabled, directly return 0 in
WM_SYSCOMMAND
.Verified on Windows 8.1.