From 350351aa24a2c5c42727bbbc06ef33fc405ec7fb Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Mon, 12 Oct 2015 10:05:39 +0000 Subject: [PATCH] [EXPLORER] - Correct tray icon image list handling. Patch by Joachim Henze CORE-10257 #resolve svn path=/trunk/; revision=69508 --- reactos/base/shell/explorer/trayntfy.cpp | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/reactos/base/shell/explorer/trayntfy.cpp b/reactos/base/shell/explorer/trayntfy.cpp index 84e8bcfe185..8e6453f4348 100644 --- a/reactos/base/shell/explorer/trayntfy.cpp +++ b/reactos/base/shell/explorer/trayntfy.cpp @@ -163,14 +163,8 @@ public: if (iconData->uFlags & NIF_ICON) { - TBBUTTONINFO tbbiOld = { 0 }; - tbbiOld.cbSize = sizeof(tbbiOld); - tbbiOld.dwMask = TBIF_BYINDEX | TBIF_IMAGE; - - GetButtonInfo(index, &tbbiOld); - tbbi.dwMask |= TBIF_IMAGE; - tbbi.iImage = ImageList_ReplaceIcon(m_ImageList, tbbiOld.iImage, iconData->hIcon); + tbbi.iImage = ImageList_ReplaceIcon(m_ImageList, index, iconData->hIcon); } if (iconData->uFlags & NIF_TIP) @@ -215,16 +209,6 @@ public: if (index < 0) return FALSE; - TBBUTTONINFO tbbiOld = { 0 }; - tbbiOld.cbSize = sizeof(tbbiOld); - tbbiOld.dwMask = TBIF_BYINDEX | TBIF_IMAGE; - - GetButtonInfo(index, &tbbiOld); - - ImageList_Remove(m_ImageList, tbbiOld.iImage); - - DeleteButton(index); - if (!(notifyItem->dwState & NIS_HIDDEN)) { m_VisibleButtonCount--; @@ -232,6 +216,22 @@ public: delete notifyItem; + ImageList_Remove(m_ImageList, index); + + int count = GetButtonCount(); + + /* shift all buttons one index to the left -- starting one index right + from item to delete -- to preserve their correct icon and tip */ + for (int i = index; i < count - 1; i++) + { + notifyItem = GetItemData(i + 1); + SetItemData(i, notifyItem); + UpdateButton(notifyItem); + } + + /* Delete the right-most, now obsolete button */ + DeleteButton(count - 1); + return TRUE; } @@ -322,7 +322,7 @@ private: LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - + INT iBtn = HitTest(&pt); if (iBtn >= 0)