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.
How fix window on top
269 views Asked by user3900678 At
2
There are 2 answers
0
On
There are two ways to make sure your window is always on top:
Constantly check in a loop if your window is still TOPMOST and set it TOPMOST if not:
if (::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) { // restore topmost }Set a system wide hook for Z-order change via
SetWindowsHookEx(WH_CBT or WH_CALLWNDPROC), and then take appropriate action when your window gets under another.
You can make your window top-most by setting the
WS_EX_TOPMOSTextended style when you create the window, or afterwards by callingSetWindowPoswithHWND_TOPMOSTas 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).