X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/396f85bac581a56e4c497b83c4602aa3746bbfd3..efebabb7ffdccdfd1400739cdbec6dc80be8a49c:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index cbda527b0e..3093583d52 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1531,12 +1531,27 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent, tvIns.item.lParam = (LPARAM)param; tvIns.item.mask = mask; + // don't use the hack below for the children of hidden root: this results + // in a crash inside comctl32.dll when we call TreeView_GetItemRect() + const bool firstChild = !IsHiddenRoot(parent) && + !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);