gpt4 book ai didi

c++ - 为什么 EnumWindows 返回的窗口比我预期的要多?

转载 作者:IT老高 更新时间:2023-10-28 22:08:55 24 4
gpt4 key购买 nike

在 VC++ 中,我使用 EnumWindows(...)、GetWindow(...) 和 GetWindowLong() 来获取窗口列表并检查窗口是否是顶部窗口(没有其他窗口作为所有者),并且窗口是否可见(WS_VISIBLE)。然而,虽然我的桌面只显示了 5 个窗口,但这个 EnumWindows 却给了我 50 个窗口,真有趣!任何 Windows 极客请帮助我澄清...

最佳答案

Raymond 在 MSDN 博客上的这篇文章中描述了在任务栏中(或类似地在 Alt-Tab 框中)仅列出窗口的方法:

Which windows appear in the Alt+Tab list?

这是检查窗口是否显示在 alt-tab 中的 super 功能:

BOOL IsAltTabWindow(HWND hwnd)
{
TITLEBARINFO ti;
HWND hwndTry, hwndWalk = NULL;

if(!IsWindowVisible(hwnd))
return FALSE;

hwndTry = GetAncestor(hwnd, GA_ROOTOWNER);
while(hwndTry != hwndWalk)
{
hwndWalk = hwndTry;
hwndTry = GetLastActivePopup(hwndWalk);
if(IsWindowVisible(hwndTry))
break;
}
if(hwndWalk != hwnd)
return FALSE;

// the following removes some task tray programs and "Program Manager"
ti.cbSize = sizeof(ti);
GetTitleBarInfo(hwnd, &ti);
if(ti.rgstate[0] & STATE_SYSTEM_INVISIBLE)
return FALSE;

// Tool windows should not be displayed either, these do not appear in the
// task bar.
if(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
return FALSE;

return TRUE;
}

这里归功于源代码:
http://www.dfcd.net/projects/switcher/switcher.c

关于c++ - 为什么 EnumWindows 返回的窗口比我预期的要多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7277366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com