Create a window using the WS_EX_NOACTIVATE flag, but you cannot drag it until I release the mouse

I created a window using the WS_EX_NOACTIVATE flag, and it works fine if you don't focus on it. However, when I drag a window or try to resize it, it does not redraw the window, because you move it and resize it, only at the very end, as soon as you release the mouse button. Is there any way around this? I would like to see the window as I resize it. I searched a lot of documents, but I still have not found permission ...

+2
c ++ windows drag
source share
2 answers

This is a Windows error. You need to call SetWindowPos(hwnd, 0, x, y, width, height, 0) on WM_MOVING . The coordinates for the set are given to you in lParam , which is RECT* .

Please note that this will activate the window in which the property is located and disconnect the owner, which you do not want (and SWP_NOACTIVATE also does not work).

To avoid this, you need to set WS_CHILD in the proper window. But install after , you created the window through SetWindowLong (), otherwise your own window will be cropped, like any child window.

And, as you probably already figured out, this only works for windows with WS_EX_TOOLWINDOW ex style. I was unable to make the paused window remain deactivated with any other style combination that does not include WS_EX_TOOLWINDOW .

This is winapi for you :(

+1
source share

If you need a window that does not focus when pressed, but you can still interact with it, you need to process WM_MOUSEACTIVATE , and return MA_NOACTIVATE .

Additional information and a fully working code example was published by Raymond Chen. See How can I get a window that rejects activation but still gets a pointer input?

+1
source share

All Articles