How to check if window is on top?
Printable View
How to check if window is on top?
To check if a window is On Top use GetWindowLong with GWL_EXSTYLE and check the WS_EX_TOPMOST bit.
Code:Dim lStyle As Long
lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
if lStyle And WS_EX_TOPMOST Then '~~> Then it's on top
It always returns zero. :confused:
Just gotta ask. Did you use the following constants:
Private Const WS_EX_TOPMOST As Long = &H8&
Private Const GWL_EXSTYLE As Long = -20
Also, GetForegroundWindow will tell you which window currently is active. Not sure exactly what you mean by "on top"
Yes, but it still returns zero.Quote:
Originally Posted by LaVolpe
Anyway I'll use GetForegroundWindow, thanks! :afrog:
You're welcome, but koolsid's reply was appropriate also. One solution checks for which window is the active one (has keyboard and mouse focus) while the other checks to see if the window has the "always on top" attribute set. The only confusion was in how each of us interpreted your "on top" meaning.