From 5188000b1df200d0a0bfe2fc77d8a026abc2737f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 26 Oct 2007 23:24:06 +0000 Subject: [PATCH] refresh the item being collapsed when using comctl32.dll v6 as otherwise parts of its selection rectangle may be left on screen git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49478 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index f7e310659d..fe5e91ee1d 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2859,17 +2859,40 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; case TVN_ITEMEXPANDED: - // the item is not refreshed properly after expansion when it has - // an image depending on the expanded/collapsed state - bug in - // comctl32.dll or our code? { NM_TREEVIEW *tv = (NM_TREEVIEW *)lParam; - wxTreeItemId id(tv->itemNew.hItem); + const wxTreeItemId id(tv->itemNew.hItem); - int image = GetItemImage(id, wxTreeItemIcon_Expanded); - if ( image != -1 ) + if ( tv->action == TVE_COLLAPSE ) { - RefreshItem(id); + if ( wxApp::GetComCtl32Version() >= 600 ) + { + // for some reason the item selection rectangle depends + // on whether it is expanded or collapsed (at least + // with comctl32.dll v6): it is wider (by 3 pixels) in + // the expanded state, so when the item collapses and + // then is deselected the rightmost 3 pixels of the + // previously drawn selection are left on the screen + // + // it's not clear if it's a bug in comctl32.dll or in + // our code (because it does not happen in Explorer but + // OTOH we don't do anything which could result in this + // AFAICS) but we do need to work around it to avoid + // ugly artifacts + RefreshItem(id); + } + } + else // expand + { + // the item is also not refreshed properly after expansion when + // it has an image depending on the expanded/collapsed state: + // again, it's not clear if the bug is in comctl32.dll or our + // code... + int image = GetItemImage(id, wxTreeItemIcon_Expanded); + if ( image != -1 ) + { + RefreshItem(id); + } } } break;