winapisetforegroundwindow

How fix window on top


I use SetForegroundWindow to set window of other application on the top. How I can fix this window on the top? It means, once some other application calls SetForegroundWindow, my window will be below my fixed window.


Solution

  • You can make your window top-most by setting the WS_EX_TOPMOST extended style when you create the window, or afterwards by calling SetWindowPos with HWND_TOPMOST as the second parameter.

    Note however there's no way to make your window stay on top of other top-most windows (i.e. there's no "on top of absolutely everything" flag).