Author: dquintana
Date: Wed May  6 22:13:06 2015
New Revision: 67583
URL: 
http://svn.reactos.org/svn/reactos?rev=67583&view=rev
Log:
[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
Modified:
    trunk/reactos/base/shell/explorer/trayntfy.cpp
Modified: trunk/reactos/base/shell/explorer/trayntfy.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/traynt…
==============================================================================
--- trunk/reactos/base/shell/explorer/trayntfy.cpp      [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/trayntfy.cpp      [iso-8859-1] Wed May  6 22:13:06
2015
@@ -256,7 +256,27 @@
         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)
         {