确定窗口是否有任务栏按钮 [英] Determining if a Window Has a Taskbar Button

查看:39
本文介绍了确定窗口是否有任务栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来检查给定窗口是否有任务栏按钮.也就是说,给定一个窗口句柄,如果窗口在任务栏中,我需要一个 TRUE,否则我需要一个 FALSE.

I am looking for a way to check if a given window has a taskbar button. That is, given a handle to a window, I need a TRUE if the window is in the taskbar, and FALSE otherwise.

相反,我想知道是否有办法获得属于给定任务栏按钮的窗口的句柄,我想这需要一种方法来枚举任务栏按钮.

Conversely, I am wondering if there is a way to get a handle to the window that belongs to a given taskbar button, which I suppose would require a way to enumerate through the taskbar buttons.

(第一个是我需要的部分,后面的部分是可选的.)

(The first former is the part that I need, and the latter part is optional.)

非常感谢.

推荐答案

Windows 使用启发式来决定是否给一个窗口一个任务栏按钮,有时它可以决定之前有一个延迟,所以这样做 100%准确地将是相当困难的.这是规则的一个粗略的开始.有一些现代风格的标志可以让您轻松了解,但如果缺少这些风格,任务栏就会变成猜测.

Windows uses heuristics to decide whether or not to give a taskbar button to a window, and sometimes there is a delay before it can decide, so doing this 100% accurately is going to be quite hard. Here's a rough start on the rules. There are modern style flags that make it easy to know, but when those styles are missing the taskbar is reduced to guessing.

首先,您需要两个窗口样式标志.

First off, you will need both of the the window style flags.

LONG Style = GetWindowLong(hwnd, GWL_STYLE);
LONG ExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

现在是规则,有3条规则是确定的.

Now the rules, there are three rules that are certain.

  • if ExStyle &WS_EX_APPWINDOW,然后是任务栏
  • if ExStyle &WS_EX_TOOLWINDOW,然后是 NOT_TASKBAR
  • if Style &WS_CHILD 然后 NOT_TASKBAR
  • if ExStyle & WS_EX_APPWINDOW, then TASKBAR
  • if ExStyle & WS_EX_TOOLWINDOW, then NOT_TASKBAR
  • if Style & WS_CHILD then NOT_TASKBAR

其他都是猜测:

  • 风格&WS_OVERLAPPED 建议任务栏
  • 风格&WS_POPUP 建议 NOT_TASKBAR 特别是如果 GetParent() != NULL
  • ExStyle &WS_EX_OVERLAPPEDWINDOW 建议任务栏
  • ExStyle &WS_EX_CLIENTEDGE 建议 NOT_TASKBAR
  • ExStyle &WS_EX_DLGMODALFRAME 建议 NOT_TASKBAR
  • Style & WS_OVERLAPPED suggests TASKBAR
  • Style & WS_POPUP suggests NOT_TASKBAR especially if GetParent() != NULL
  • ExStyle & WS_EX_OVERLAPPEDWINDOW suggests TASKBAR
  • ExStyle & WS_EX_CLIENTEDGE suggests NOT_TASKBAR
  • ExStyle & WS_EX_DLGMODALFRAME suggests NOT_TASKBAR

我确信还有其他的猜测规则,事实上,猜测规则已经随着 Windows 版本的不同而变化.

I'm sure that there are other rules for guessing, and in fact that the guessing rules have changed from version to version of Windows.

这篇关于确定窗口是否有任务栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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