Collapsing all branches

Have you ever had the experience that you have expanded the outline at
various points causing a lot of items to be visible and then finding it
difficult to locate a particular item. Well, it happens with me all the
time. So heres the code that will collapse all the branches in the outline
as if the treeview control has just been initialized with the data.


// CollapseAll  – Collapses the complete outline.
void CTreeCtrlX::CollapseAll()
        HTREEITEM hti = GetRootItem();
                CollapseBranch( hti );
        }while( (hti = GetNextSiblingItem( hti )) != NULL );

This uses the function we developed for collapsing a branch. It goes through
all the root items and collapses them.

More by Author

Must Read