jon*_*ham 17 c++ windows styles visual-c++
在VC++中,我使用EnumWindows(...),GetWindow(...)和GetWindowLong()来获取窗口列表并检查窗口是否是顶部窗口(没有其他窗口作为所有者),以及窗口是否是可见的(WS_VISIBLE).然而,虽然我的桌面只显示了5个窗口,但这个EnumWindows给了我50个窗口,多么有趣!任何Windows极客都请帮我澄清一下......
jon*_*ham 32
Raymond在MSDN博客上的这篇文章中描述了仅列出任务栏中的窗口(或类似地在Alt-Tab框中)的方法:http:
//blogs.msdn.com/b/oldnewthing/archive/2007/10/08 /5351207.aspx
这是检查alt-tab中是否显示窗口的超级函数:
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;
}
Run Code Online (Sandbox Code Playgroud)
在此处归功于源代码:http:
//www.dfcd.net/projects/switcher/switcher.c
| 归档时间: |
|
| 查看次数: |
6080 次 |
| 最近记录: |