]> git.saurik.com Git - wxWidgets.git/commitdiff
fix for GetParent() in wxTR_HIDE_ROOT case
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Mar 2002 15:10:12 +0000 (15:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Mar 2002 15:10:12 +0000 (15:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index 242eab62b1e51998924a14c590c28aeb4d42eacd..298bd387442903150f7898a0c81b5ca5c85973ef 100644 (file)
@@ -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);