From f6f2e8dbacd0d716f3caa818e3ad1f7ffaa98e21 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Wed, 6 May 2015 22:13:06 +0000 Subject: [PATCH] [EXPLORER] Remove notification icons when their attached HWND is no longer valid. Patch by Joachim Henze (reactosfanboy), with some extra newlines by me. CORE-9537 #resolve svn path=/trunk/; revision=67583 --- reactos/base/shell/explorer/trayntfy.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/reactos/base/shell/explorer/trayntfy.cpp b/reactos/base/shell/explorer/trayntfy.cpp index ec502cf916e..a7a54ace83e 100644 --- a/reactos/base/shell/explorer/trayntfy.cpp +++ b/reactos/base/shell/explorer/trayntfy.cpp @@ -256,7 +256,27 @@ private: NOTIFYICONDATA * notifyItem = GetItemData(wIndex); if (!::IsWindow(notifyItem->hWnd)) + { + // We detect and destroy icons with invalid handles only on mouse move over systray, same as MS does. + // Alternatively we could search for them periodically (would waste more resources). + TRACE("destroying icon with invalid handle\n"); + + HWND parentHWND = GetParent(); + parentHWND = ::GetParent(parentHWND); + + RECT windowRect; + ::GetClientRect(parentHWND, &windowRect); + + RemoveButton(notifyItem); + + SendMessage(parentHWND, + WM_SIZE, + 0, + MAKELONG(windowRect.right - windowRect.left, + windowRect.bottom - windowRect.top)); + return; + } if (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) {