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