Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CTreeCtrl::SortChildrenCB only seems to call my sort callback function once. Isnt this function recursive?

164 views
Skip to first unread message

andys

unread,
Jan 11, 2006, 6:52:26 AM1/11/06
to
Has anyone got any ideas on why my CTreeCtrl is only calling my sort
callback function once? Im adding my Items (TV_ITEM's) and the setting
lParam to my data.

When i call the sort function my callback is called correctly for the
direct children of the root, but it does not continue to get called for
the children of these items!

Im calling the sort function:

TVSORTCB stSort;
stSort.hParent = GetTreeCtrl().GetRootItem();
stSort.lpfnCompare = CLeftView::sortTreeProc;
stSort.lParam = (LPARAM) &GetTreeCtrl();
this->GetTreeCtrl().SortChildrenCB(&stSort);

Has anyone got any ideas on why this is happening? Is it something to
do with the stSort.hParent ? I have tried setting this to TVI_ROOT, but
this made no difference.

Also, if anyone knows of where i can find a sample it would be
appreciated.

Cheers,

Andy

Simon Trew

unread,
Jan 11, 2006, 11:11:54 AM1/11/06
to
CTreeCtrl::SortChildrenCB is silent on the matter, but the documentation for
CTreeCtrl::SortChildren says:

Remarks
Call this function to sort the child items of the given parent item in a
tree view control. SortChildren will not recurse through the tree; only the
immediate children of hItem will be sorted.

I presume SortChildrenCB is the same-- you have to recurse through the
children yourself. When you think about it, this makes sense (at least as a
default), since you might want different tree nodes' children sorted in
different ways, depending on what they represent.


0 new messages