From fc7282961f5c8021060f46301bbf2ae9733c6752 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 14 Feb 2006 19:42:12 +0000 Subject: Fixed bug where pieces would be added multiple times when expanding a category. git-svn-id: http://svn.leocad.org/trunk@476 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/Piecebar.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'win/Piecebar.cpp') diff --git a/win/Piecebar.cpp b/win/Piecebar.cpp index dae325f..1975b2f 100644 --- a/win/Piecebar.cpp +++ b/win/Piecebar.cpp @@ -1016,8 +1016,26 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if (Notify->action == TVE_EXPAND) { + m_PiecesTree.SetRedraw(FALSE); + PiecesLibrary *Lib = lcGetPiecesLibrary(); + // Remove all children. + HTREEITEM Item = Notify->itemNew.hItem; + + if (m_PiecesTree.ItemHasChildren(Item)) + { + HTREEITEM NextItem; + HTREEITEM ChildItem = m_PiecesTree.GetChildItem(Item); + + while (ChildItem != NULL) + { + NextItem = m_PiecesTree.GetNextItem(ChildItem, TVGN_NEXT); + m_PiecesTree.DeleteItem(ChildItem); + ChildItem = NextItem; + } + } + // Check if we're expanding a category item. if (Notify->itemNew.lParam == NULL) { @@ -1079,20 +1097,6 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) Pieces.Sort(PiecesSortFunc, NULL); HTREEITEM ParentItem = Notify->itemNew.hItem; - // Remove all children (for some reason TVE_COLLAPSERESET isn't always working). - if (m_PiecesTree.ItemHasChildren(ParentItem)) - { - HTREEITEM NextItem; - HTREEITEM ChildItem = m_PiecesTree.GetChildItem(ParentItem); - - while (ChildItem != NULL) - { - NextItem = m_PiecesTree.GetNextItem(ChildItem, TVGN_NEXT); - m_PiecesTree.DeleteItem(ChildItem); - ChildItem = NextItem; - } - } - for (int i = 0; i < Pieces.GetSize(); i++) { PieceInfo* Info = Pieces[i]; @@ -1113,6 +1117,9 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) m_PiecesTree.InsertItem(TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, ParentItem, TVI_LAST); } } + + m_PiecesTree.SetRedraw(TRUE); + m_PiecesTree.Invalidate(); } else if (Notify->action == TVE_COLLAPSE) { -- cgit v1.2.3