From c9b142c9f8a33853c9183df8304bd6fe8d945964 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Mar 2002 15:10:12 +0000 Subject: [PATCH] fix for GetParent() in wxTR_HIDE_ROOT case git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 242eab62b1..298bd38744 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1298,11 +1298,21 @@ wxTreeItemId wxTreeCtrl::GetSelection() const wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const { - HTREEITEM hItem = TreeView_GetParent(GetHwnd(), HITEM(item)); - if ( !hItem && HasFlag(wxTR_HIDE_ROOT) ) + HTREEITEM hItem; + + if ( IS_VIRTUAL_ROOT(item) ) + { + // no parent for the virtual root + hItem = 0; + } + else // normal item { - // the top level items should have the virtual root as their parent - hItem = TVI_ROOT; + hItem = TreeView_GetParent(GetHwnd(), HITEM(item)); + if ( !hItem && HasFlag(wxTR_HIDE_ROOT) ) + { + // the top level items should have the virtual root as their parent + hItem = TVI_ROOT; + } } return wxTreeItemId((WXHTREEITEM)hItem); -- 2.50.0