It's a well known tip how to make your window topmost or "Always on Top".
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Well, how can you determine if your window is topmost? You can do it like this:
if (::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
... else
...
This is because
SetWindowsPos()
gives
WS_EX_TOPMOST
extended style to your window when it makes the window topmost.