Why do some buttons on the taskbar disappear at one point

Scorpion

Sometimes, you will find such a phenomenon: after clicking a blank button on the taskbar, the button disappears. Why is this? On MSDN, there is an article "some basic rules on which windows go into the taskbar" that gives some introduction, in short:
>  If a window is set with WS_EX_APPWINDOW style, it will be displayed on the taskbar.
>  If a window is top-level and not owned, it will be displayed on the taskbar.
>  All other conditions will not be displayed on the taskbar.

(Although the ITaskbarList interface makes things a bit complicated), when a taskbar-eligible window becomes visible, the taskbar will create a button for the window. When it becomes hidden, the taskbar will remove this button. If the state of the window is between taskbar-eligible and taskbar-ineligible, when the window is visible, a blank button will be displayed on the taskbar .

Consider the following behavior pattern

>The  window is perceptible to the taskbar.
>  If the window becomes visible, the taskbar button is created.
>The  window becomes imperceptible to the taskbar.
>The  window becomes invisible, because the window is not perceivable by the taskbar at this time, so the taskbar ignores this change.

The result

A button that is not attached to any window will appear in the taskbar. This is also the document’s suggestion: "If you want to dynamically set the style of a window to a style that does not support taskbar buttons, you must first hide the window (by passing in SW_HIDE to ShowWindow), and then modify the window Style, and finally the window is displayed."

Here comes the problem

Why doesn't the taskbar monitor the display and hiding of all windows?

answer

Because this operation is very expensive.
The action of filtering out windows that do not meet the conditions of the taskbar takes place inside the USER32 module. Only when the status of the eligible windows of the taskbar changes, it will notify the taskbar through HSHELL* notification messages (or any WH_SHELL hook installed) s component). This way, the taskbar code will not be paged in when there is nothing to do.

to sum up

The state interaction here is quite complicated. Wait a minute, let me shed light on this matter. . .

At last

Raymond Chen's "The Old New Thing" is one of my favorite blogs. It contains a lot of little knowledge about Windows, which is really helpful for the majority of Windows platform developers.
This article comes from: "What's with those blank taskbar buttons that go away when I click on them?"

Guess you like

Origin blog.csdn.net/mmxida/article/details/108587685