VC++ 判斷你的窗口是否置頂TopMost


  大家可能已經知道,使你的窗口置頂(TopMost)或者總是最前(Always on Top)的方法:

 C++ Code 
1
2
3
4
5
 
// Make topmost
::SetWindowPos(hwnd, HWND_TOPMOST0000SWP_NOMOVE SWP_NOSIZE);
 
// Revert back
::SetWindowPos(hwnd, HWND_NOTOPMOST0000SWP_NOMOVE SWP_NOSIZE);

  但是,你如何決定自己的窗口是否為TopMost狀態?哈哈,可以這樣來做:

 C++ Code 
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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM