Don't use wxTreeCtrl item insertion workaround under modern MSW
Don't refresh the control unnecessarily after inserting the first child node when using modern (i.e. post-XP) MSW version, this just slows down inserting of the first child item in big trees. Closes https://github.com/wxWidgets/wxWidgets/pull/555
This commit is contained in:
committed by
Vadim Zeitlin
parent
81d9952dfe
commit
6c01707627
@@ -1505,9 +1505,16 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
|
|||||||
tvIns.item.lParam = (LPARAM)param;
|
tvIns.item.lParam = (LPARAM)param;
|
||||||
tvIns.item.mask = mask;
|
tvIns.item.mask = mask;
|
||||||
|
|
||||||
// don't use the hack below for the children of hidden root: this results
|
// apparently some Windows versions (2000 and XP are reported to do this)
|
||||||
// in a crash inside comctl32.dll when we call TreeView_GetItemRect()
|
// sometimes don't refresh the tree after adding the first child and so we
|
||||||
const bool firstChild = !IsHiddenRoot(parent) &&
|
// need this to make the "[+]" appear
|
||||||
|
//
|
||||||
|
// don't use this hack below for the children of hidden root nor for modern
|
||||||
|
// MSW versions as it would just unnecessarily slow down the item insertion
|
||||||
|
// at best
|
||||||
|
const bool refreshFirstChild =
|
||||||
|
(wxGetWinVersion() < wxWinVersion_Vista) &&
|
||||||
|
!IsHiddenRoot(parent) &&
|
||||||
!TreeView_GetChild(GetHwnd(), HITEM(parent));
|
!TreeView_GetChild(GetHwnd(), HITEM(parent));
|
||||||
|
|
||||||
HTREEITEM id = TreeView_InsertItem(GetHwnd(), &tvIns);
|
HTREEITEM id = TreeView_InsertItem(GetHwnd(), &tvIns);
|
||||||
@@ -1516,10 +1523,7 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
|
|||||||
wxLogLastError(wxT("TreeView_InsertItem"));
|
wxLogLastError(wxT("TreeView_InsertItem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// apparently some Windows versions (2000 and XP are reported to do this)
|
if ( refreshFirstChild )
|
||||||
// sometimes don't refresh the tree after adding the first child and so we
|
|
||||||
// need this to make the "[+]" appear
|
|
||||||
if ( firstChild )
|
|
||||||
{
|
{
|
||||||
TVGetItemRectParam param2;
|
TVGetItemRectParam param2;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user