views:

89

answers:

2

SetWindowPosition second parameter is hWndInsertAfter which means behind. How do I place a window in front of another (above)?

A: 

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.

Terry Mahaffey
A: 

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

pulp