Alt+Tab 菜单的 HWND(按顺序) [英] HWNDs of Alt+Tab Menu (In Order)

查看:19
本文介绍了Alt+Tab 菜单的 HWND(按顺序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xy 问题,请原谅 (HWND 的上次活动时间 - 获取上次活动的 hwnd).本主题解决了这个问题.

I got an xy question situation so excuse that please (Last activity time of HWND - get the last active hwnd). This topic fixes that.

我需要按 alt+tab 菜单的显示顺序获取 HWND 的数组.

I need to get an array of the HWNDs, in order as they show, of the alt+tab menu.

我正在考虑这样做:使用 MSDN :: GetAltTabInfo 我想我也提供了一个 HWND 并且它吐了回来:

I was thinking of doing this: Use MSDN :: GetAltTabInfo which I think i provide an HWND too and it spits back:

typedef struct tagALTTABINFO {
  DWORD cbSize;
  int   cItems;
  int   cColumns;
  int   cRows;
  int   iColFocus;
  int   iRowFocus;
  int   cxItem;
  int   cyItem;
  POINT ptStart;
} ALTTABINFO, *PALTTABINFO, *LPALTTABINFO;

在 alt 选项卡菜单中,cxItem 和 cyItem 在哪里给出 HWND 的位置?

Where cxItem and cyItem give the location of the HWND in the alt tab menu?

这是这样工作的吗?这是我应该采取的方式吗?我必须先知道一个 HWND,然后使用上面的这个功能在 alt+tab 菜单中测试它的位置?

Is this how that works? Is this the way I should take? I have to know an HWND first then test for its location in alt+tab menu with this function above?

或者有没有办法按照 alt+tab 菜单的顺序列出 HWND?

Or is there some way to list out the HWNDs in order of the alt+tab menu?

推荐答案

需要使用 GetTopWindow/GetNextWindow 以 Z 顺序枚举桌面的孩子,然后测试样式以查看它是否有资格出现在 alt+tab 列表中.类似的东西:

You need to use GetTopWindow/GetNextWindow to enumerate through the desktop's children in Z order, and then test the style to see if it's eligible to be in the alt+tab list. Something like:

HWND child = GetTopWindow(NULL);
LONG mask = WS_VISIBLE | WS_CAPTION;

while (child != NULL)
{
    LONG style = GetWindowLong(child, GWL_STYLE);

    if ((style & mask) == mask)
    {
        // do something with child.
    }

    child = GetNextWindow(child, GW_HWNDNEXT);
}

这篇关于Alt+Tab 菜单的 HWND(按顺序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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