开发者

I can use SetWindowPos to place the window behind another window, but how do I place it in front of a given window?

开发者 https://www.devze.com 2022-12-19 06:05 出处:网络
SetWindowPosition second parameter is hWnd开发者_开发知识库InsertAfter which means behind. How do I place a window in front of another (above)? How about you call SetWindowPos again, swapping the hwnd

SetWindowPosition second parameter is hWnd开发者_开发知识库InsertAfter which means behind. How do I place a window in front of another (above)?


How about you call SetWindowPos again, swapping the hwnd parameters (so your original window is now the hWndInsertAfter, and the initial hWndInsertAfter is now the hWnd you're moving), and passing in the SWP_NOMOVE flag?

Edit: And if the exact position in the Z-order doesn't matter and you just want it in front, don't forget about SetForegroundWindow.


if the z-order looks like that:

z-oder -> desktop_window-> window a -> window b

and you want to set your window above window a, set hWndInsertAfter to window b, if you want to set your window above window b, use the HWND_TOP flag

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号