0

使用 WS_EX_TOOLWINDOW 标志时是否可以显示任务栏按钮CreateWindowEx

4

1 回答 1

0

The WS_EX_APPWINDOW style is required for an unowned top-level window to display itself on the Taskbar.

The Extended Window Styles documentation specifically states that a "tool window does not appear in the taskbar".

MSDN further documents this in more detail:

The Taskbar

The Shell places a button on the taskbar whenever an application creates an unowned window—that is, a window that does not have a parent and that has the appropriate extended style bits (see Managing Taskbar Buttons, below).

...

Managing Taskbar Buttons

The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.

The Shell will remove a window's button from the taskbar only if the window's style supports visible taskbar buttons. If you want to dynamically change a window's style to one that does not support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.

...

Modifying the Contents of the Taskbar

Version 4.71 and later of Shell32.dll adds the capability to modify the contents of the taskbar. From an application, you can now add, remove, and activate taskbar buttons. Activating the item does not activate the window; it shows the item as pressed on the taskbar.

The taskbar modification capabilities are implemented in a Component Object Model (COM) object (CLSID_TaskbarList ) that exposes the ITaskbarList interface (IID_ITaskbarList). You must call the ITaskbarList::HrInit method to initialize the object. You can then use the methods of the ITaskbarList interface to modify the contents of the taskbar.

So, you might be able to use ITaskbarList::AddTab() for your tool window:

Any type of window can be added to the taskbar, but it is recommended that the window at least have the WS_CAPTION style.

于 2017-02-20T18:17:33.797 回答