Detecting whether a window is topmost
-
How can I determine whether a window on the desktop is a topmost window or not. I need to bring a window momentarily to the top (with HWND_TOPMOST), and then to restore it back to the position it was. I can use GetWindow(hWnd, HWND_RREV) to determine the previous window, and use this handle in SetWindowPos(). But since I have altered the TOPMOST position, how do I restore it?
-
How can I determine whether a window on the desktop is a topmost window or not. I need to bring a window momentarily to the top (with HWND_TOPMOST), and then to restore it back to the position it was. I can use GetWindow(hWnd, HWND_RREV) to determine the previous window, and use this handle in SetWindowPos(). But since I have altered the TOPMOST position, how do I restore it?
Would
GetForegroundWindow()
be of any use?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Would
GetForegroundWindow()
be of any use?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
The window might be topmost, but not on the foreground. For example, We can set MSN to Always on top, and the task manager, which is always on top. Both of these are topmost windows, but any of them could be in the foreground. The following line solved the problem: bool isTopmost = GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST