X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9c1265fcad7d69e22647c6a598c91cbfb26faee..a582395301f296706dc9e59d0346cddd165eacd8:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 242eab62b1..ee2a775b34 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -303,27 +303,24 @@ struct wxTreeViewItem : public TV_ITEM // wxVirutalNode is used in place of a single root when 'hidden' root is // specified. -class wxVirtualNode +class wxVirtualNode : public wxTreeViewItem { public: wxVirtualNode(wxTreeItemData *data) + : wxTreeViewItem(TVI_ROOT, 0) { m_data = data; - - m_tvItem = new wxTreeViewItem(TVI_ROOT, 0); } ~wxVirtualNode() { delete m_data; - delete m_tvItem; } wxTreeItemData *GetData() const { return m_data; } void SetData(wxTreeItemData *data) { delete m_data; m_data = data; } private: - wxTreeViewItem *m_tvItem; wxTreeItemData *m_data; }; @@ -1298,11 +1295,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) ) { - // the top level items should have the virtual root as their parent - hItem = TVI_ROOT; + // no parent for the virtual root + hItem = 0; + } + else // normal item + { + 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); @@ -1507,7 +1514,7 @@ wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, return TVI_ROOT; } - return DoInsertItem(wxTreeItemId((WXHTREEITEM) 0), (WXHTREEITEM) 0, + return DoInsertItem(wxTreeItemId((long)(WXHTREEITEM) 0), (long)(WXHTREEITEM) 0, text, image, selectedImage, data); }