如何检查窗口是否“始终在顶部"? [英] How to check if window is "Always on top"?

查看:18
本文介绍了如何检查窗口是否“始终在顶部"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我有用的热键程序中,我有一个全局热键,它通过调用

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" :)

这篇关于如何检查窗口是否“始终在顶部"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆