Topmost Windows

A topmost window is a window that has the WS_EX_TOPMOST style. Topmost windows are above all non-topmost sibling windows in the Z order. You can create a topmost window directly by specifying the WS_EX_TOPMOST style when you create the window. You can also make a window a topmost window by calling the SetWindowPos function and setting the hWndInsertAfter parameter to HWND_TOPMOST.

A window may lose its topmost style by calling SetWindowPos and setting the hWndInsertAfter parameter to HWND_NOTOPMOST. If a window is positioned directly after a non-topmost window, then that window loses its WS_EX_TOPMOST style.

Do not confuse topmost with top-level. Top-level refers to whether or not a window has a parent, whereas topmost refers to a specific style that controls the Z order for the window.

You can set the SetWindowLong function to give a the window the WS_EX_TOPMOST style. However, this function does not change the windows Z order.