summaryrefslogtreecommitdiff
path: root/win/Piecebar.cpp
diff options
context:
space:
mode:
authorleo2006-02-14 19:42:12 +0000
committerleo2006-02-14 19:42:12 +0000
commitfc7282961f5c8021060f46301bbf2ae9733c6752 (patch)
tree3e27b7b9abdc45f34dc576d4ea803301e60b920b /win/Piecebar.cpp
parent4f990e858dbbe25fdc42f7d3f1d89191f11d2151 (diff)
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
Diffstat (limited to 'win/Piecebar.cpp')
-rw-r--r--win/Piecebar.cpp35
1 files changed, 21 insertions, 14 deletions
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)
{