問題描述
在我有用的熱鍵程序中,我有一個全局熱鍵,它通過調用
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 和 Win+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 中找不到可以讓您檢查 windows z 順序的函數.我希望有類似 GetWindowOrder 的東西,但沒有.我也試過像這樣檢查 windows ex 標志:
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.
有沒有檢查這個的功能?
Is there a function to check this?
推薦答案
我認為你可以這樣做:
DWORD dwExStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
if ((dwExStyle & WS_EX_TOPMOST) != 0)
{
// do stuff
}
這是 MSDN 鏈接 - http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx
Here's the MSDN link - http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx
這里是擴展樣式的 MSDN 鏈接 - http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx - topmost 目前被列為待定":)
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" :)
這篇關于如何檢查窗口是否“始終在頂部"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!