From: Vadim Zeitlin Date: Thu, 10 Jul 2003 11:04:37 +0000 (+0000) Subject: keep selected image in sync with the normal one if it hasn't been changed (patch... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7ab0c3adb780464f2ee58f88d2443f5a79a2c401 keep selected image in sync with the normal one if it hasn't been changed (patch 754906) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 5dcb0867c0..d494219360 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1012,15 +1012,28 @@ void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image, return; } - int imageNormal, imageSel; + int imageNormal, + imageSel; + switch ( which ) { default: wxFAIL_MSG( wxT("unknown tree item image type") ); + // fall through case wxTreeItemIcon_Normal: - imageNormal = image; - imageSel = GetItemSelectedImage(item); + { + const int imageNormalOld = GetItemImage(item); + const int imageSelOld = GetItemSelectedImage(item); + + // always set the normal image + imageNormal = image; + + // if the selected and normal images were the same, they should + // be the same after the update, otherwise leave the selected + // image as it was + imageSel = imageNormalOld == imageSelOld ? image : imageSelOld; + } break; case wxTreeItemIcon_Selected: