CTreeCtrl SortChildren problem
Peter T. O'Neill -- oneillpt@acadamh.ucd.ie
Thursday, November 14, 1996
Environment: VC++ 4.0, Win 95
I have a sorting problem with CTreeCtrl:
m_pTreeCtrl->SortChildren( m_htiRoot);
// m_pTreeCtrl->SortChildren( NULL );
If I specify NULL the Tree Control is NOT sorted at all. If I specify
m_htiRoot, as above, the child items of that parent item are sorted,
but their child items are not. I read the documentation (extract
below) to mean that I should be using NULL to sort the entire tree,
including children of children, which is what I want to do, but it
does not work for me. Any suggestions?
hItem Handle of the parent item whose child items are to be sorted.
Remarks
Call this function to sort the child items of the given parent item
in a tree view control. If hItem is NULL, the entire tree control is
sorted.
-----------------------------------------------------------------
Peter O'Neill, Mech. Eng. Dept., UCD, Belfield, Dublin 4, Ireland
Phone: +353-1-706 1889
Fax: +353-1-283 0534
http://poneill.ucd.ie/
Jim Barry -- Jim.Barry@ilp.com
Saturday, November 16, 1996
[Mini-digest: 2 responses]
On 14 November 1996 16:37, Peter T. O'Neill[SMTP:oneillpt@acadamh.ucd.ie] wrote:
>Environment: VC++ 4.0, Win 95
>
>I have a sorting problem with CTreeCtrl:
>
> m_pTreeCtrl->SortChildren( m_htiRoot);
>// m_pTreeCtrl->SortChildren( NULL );
>
>If I specify NULL the Tree Control is NOT sorted at all. If I specify
>m_htiRoot, as above, the child items of that parent item are sorted,
>but their child items are not. I read the documentation (extract
>below) to mean that I should be using NULL to sort the entire tree,
>including children of children, which is what I want to do, but it
>does not work for me. Any suggestions?
>
>hItem Handle of the parent item whose child items are to be sorted.
>Remarks
>Call this function to sort the child items of the given parent item
>in a tree view control. If hItem is NULL, the entire tree control is
>sorted.
>
>-----------------------------------------------------------------
>Peter O'Neill, Mech. Eng. Dept., UCD, Belfield, Dublin 4, Ireland
>Phone: +353-1-706 1889
>Fax: +353-1-283 0534
>http://poneill.ucd.ie/
>
>
Yes, SortChildren only sorts immediate children, so you have to implement the recursion yourself.
Jim Barry
Interactive Learning Productions
Newcastle upon Tyne, UK
-----From: "Rammohan Rao K. V."
I had same problem while using NULL to sort the complete tree. I called
SortChildren() recursively to sort all levels.
CMyTree::Sort(HTREEITEM hItem)
{
if(hItem)
{
SortChildren(hItem);
HTREEITEM hChildItem = GetChildItem(hItem);
while(hChildItem)
{
Sort(hChildItem);
hChildItem = GetNextSiblingItem(hChildItem);
}
}
}
Call this with
Sort(GetRootItem());
Rammohan
____________________________________________________________________
K.V.Rama Mohana Rao
Project Leader
Sierra Optima Ltd
# 503, Software Technology Park
Maitrivanam, HUDA Complex
Ameerpet, Hyderabad - 5000 038
AP, INDIA
Work : (91)-40-292771, 290321
Fax : (91)-40-294810
_____________________________________________________________________
| Вернуться в корень Архива
|