]> git.saurik.com Git - wxWidgets.git/commitdiff
refresh the item after adding its first child as, apparently, otherwise the '+' is...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 15:37:52 +0000 (15:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 15:37:52 +0000 (15:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53051 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index cbda527b0e1074d622622248af1ad5b18d6ea087..4a8d830be20bd1023461512965bfd19c0b54d0ec 100644 (file)
@@ -1531,12 +1531,24 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
     tvIns.item.lParam = (LPARAM)param;
     tvIns.item.mask = mask;
 
+    const bool firstChild = !TreeView_GetChild(GetHwnd(), HITEM(parent));
+
     HTREEITEM id = TreeView_InsertItem(GetHwnd(), &tvIns);
     if ( id == 0 )
     {
         wxLogLastError(wxT("TreeView_InsertItem"));
     }
 
+    // apparently some Windows versions (2000 and XP are reported to do this)
+    // sometimes don't refresh the tree after adding the first child and so we
+    // need this to make the "[+]" appear
+    if ( firstChild )
+    {
+        RECT rect;
+        TreeView_GetItemRect(GetHwnd(), HITEM(parent), &rect, FALSE);
+        ::InvalidateRect(GetHwnd(), &rect, FALSE);
+    }
+
     // associate the application tree item with Win32 tree item handle
     param->SetItem(id);