7

Why is the HSHELL_WINDOWDESTROYED notification raised when a window is hidden, e...

 3 years ago
source link: https://devblogs.microsoft.com/oldnewthing/20201228-00/?p=104610
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Why is the HSHELL_WINDOWDESTROYED notification raised when a window is hidden, even if it hasn't been destroyed?

Why is the HSHELL_WINDOWDESTROYED notification raised when a window is hidden, even if it hasn’t been destroyed?

Raymond Chen

Raymond

December 28th, 2020

The shell notification HSHELL_WINDOW­CREATED means that there is a new top-level unowned visible window. Conversely, HSHELL_WINDOW­DESTROYED means that a window is no longer a top-level unowned visible window. But these state changes can occur for reasons other than a window being created and destroyed. For example, if a top-level window hides itself, then that will generate a HSHELL_WINDOW­DESTROYED notification, even though no window was destroyed.

Why don’t the names align with what they mean?

These notifications were named while wearing taskbar-colored glasses.

These notifications were created to assist the taskbar in keeping track of the windows in the system. The taskbar shows top-level unowned visible windows, so that’s what the notifications pay attention to. If you hide a top-level unowned window, it hasn’t been destroyed, but it may as well have been destroyed as far as the taskbar is concerned: The window disappears from the taskbar.

Conversely, when the window becomes visible again, it gains a taskbar button. As far as the taskbar is concerned, it may as well have been newly-created.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK