如何检查窗口"总在最前面"? [英] How to check if window is "Always on top"?
问题描述
在我有用的热键的程序,我有一个全局热键它设置当前的前景窗口是最顶层/未通过调用最顶层
In my useful hotkeys program, i have a global hotkey which sets your current foreground window to be Topmost/Not topmost by calling
SetWindowPos(hwnd, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
SetWindowPos(hwnd, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
目前,我必须有两个独立的快捷键,WIN + Z到窗口设置为TOPMOST anjd赢+ X到窗口设置为NOTOPMOST。
at the moment i have to have two separate hotkeys, Win+Z to set window to TOPMOST anjd Win+X to set window to NOTOPMOST.
我找不到一个MSDN的功能,它可以让你检查窗口Z序..我希望这样的事情GetWindowOrder,但是没有。我也尝试过检查窗户前的标志,像这样:
I can't find a function in MSDN which lets you check the windows z order.. i was hoping for something like GetWindowOrder, but there isn't. I also tried checking the windows ex flags like so:
dwExStyles & WS_EX_TOPMOST
但似乎标志不从未改变,它只是告诉窗口最上面的设置本身时,其第一个创建的。
but it seems that flag isn't never changed, it just tells the window to set itself topmost when its first created.
有没有检查这个功能?
推荐答案
我觉得你可以这样做:
DWORD dwExStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
if ((dwExStyle & WS_EX_TOPMOST) != 0)
{
// do stuff
}
这里的MSDN链接 - <一个href=\"http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx\">http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx
和这里的MSDN链接扩展样式 - <一个href=\"http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx\">http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx - 最顶层目前列为待定:)
And here's the MSDN link to the extended styles - http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx - topmost is currently listed as "TBD" :)
这篇关于如何检查窗口&QUOT;总在最前面&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!