I have created a window using the WS_EX_NOACTIVATE flag and it works great as far as not taking focus when you click the window. However when I drag the window or try to resize
It's a Windows bug. You need to call SetWindowPos(hwnd, 0, x, y, width, height, 0)
on WM_MOVING
. The coordinates to set are given to you in lParam
which is a RECT*
.
Note that doing this will activate the owned window and deactivate the owner, which is not what you want (and SWP_NOACTIVATE
has no effect either).
To avoid that, you need to set WS_CHILD on the owned window. But set it after you created the window, via SetWindowLong(), otherwise your owned window will get clipped, like any child window.
And, as you probably already figured out, this only works for windows with WS_EX_TOOLWINDOW
ex style. I wasn't able to make the owned window stay deactivated with any other style combination that doesn't include WS_EX_TOOLWINDOW
.
That's winapi for you :(