Home > other >  SetWindowsHookEx(WH_SHELL, ...): What is the meaning of event HSHELL_WINDOWREPLACED?
SetWindowsHookEx(WH_SHELL, ...): What is the meaning of event HSHELL_WINDOWREPLACED?

Time:03-08

If I register a hook via SetWindowsHookEx(WH_SHELL, ShellProc, ...), what is the meaning of event HSHELL_WINDOWREPLACED? (My Google-fu fails me. I have searched high and low!)

Win32 Docs:

The offical docs read: A top-level window is being replaced. Weirdly, they also say: Windows 2000: Not supported. Does that mean only supported before or after Win2K?

I created a test driver to watch a Microsoft Windows session, but I was never able to trigger this mysterious event.

I also found a similar event here:

... that says:

  • HSHELL_WINDOWREPLACING: A handle to the window replacing the top-level window.
  • HSHELL_WINDOWREPLACED: A handle to the window being replaced.

Related: How can I be notified when a new window is created on Win32?

CodePudding user response:

In this instance, the term "replace" refers to the occasions when a window stops responding to messages ("hangs") and, after a certain period, Windows hides it and replaces it on-screen with a faded-out copy (called a "ghost window").

Windows does this so that, even when the app is not processing messages, the user can interact with the ghost window to move it around and try to close it.

The wParam value is the handle of the hung window (the one being replaced) and the lParam value is the handle of the ghost window (its replacement).

If the window starts responding again, the notification is sent again, with the window handles swapped around.

  • Related