VC++ 判斷你的窗口是否置頂TopMost
阿新 • • 發佈:2017-11-09
set 同時 width div consola ++ pro ble -i
大家可能已經知道,使你的窗口置頂(TopMost)或者總是最前(Always on Top)的方法:
C++ Code
1 2 3 4 5 |
// Make topmost ::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // Revert back ::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
但是,你如何決定自己的窗口是否為TopMost 狀態?哈哈,可以這樣來做:
1 2 3 4 5 6 7 8 |
if (::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) { ... // The window is topmost. } else { ... // The window is not topmost. } |
解釋:當SetWindowsPos()使窗口TopMost時,也同時為窗口提供了
WS_EX_TOPMOST
擴展樣式。.
出處:https://www.codeproject.com/Tips/269140/How-to-determine-if-your-window-is-topmost
VC++ 判斷你的窗口是否置頂TopMost