diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 5eeede8598..341f31b528 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -304,6 +304,9 @@ private: // item visually spans the entire breadth of the window then bool MSWIsOnItem(unsigned flags) const; + // Delete the given item from the native control. + bool MSWDeleteItem(const wxTreeItemId& item); + // the hash storing the items attributes (indexed by item ids) wxMapTreeAttr m_attrs; diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 54211597c1..8f664ffa2f 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1598,6 +1598,18 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent, return DoInsertAfter(parent, idPrev, text, image, selectedImage, data); } +bool wxTreeCtrl::MSWDeleteItem(const wxTreeItemId& item) +{ + TempSetter set(m_changingSelection); + if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) ) + { + wxLogLastError(wxT("TreeView_DeleteItem")); + return false; + } + + return true; +} + void wxTreeCtrl::Delete(const wxTreeItemId& item) { // unlock tree selections on vista, without this the @@ -1619,14 +1631,8 @@ void wxTreeCtrl::Delete(const wxTreeItemId& item) } } - { - TempSetter set(m_changingSelection); - if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) ) - { - wxLogLastError(wxT("TreeView_DeleteItem")); - return; - } - } + if ( !MSWDeleteItem(item) ) + return; if ( !selected ) { @@ -1657,10 +1663,7 @@ void wxTreeCtrl::Delete(const wxTreeItemId& item) } else { - if ( !TreeView_DeleteItem(GetHwnd(), HITEM(item)) ) - { - wxLogLastError(wxT("TreeView_DeleteItem")); - } + MSWDeleteItem(item); } }