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)
This is because
extended style to your window when it makes the window topmost.