Traversing a CTreeCtrl ???

Traversing a CTreeCtrl ???

Post by Peter Worcest » Fri, 05 Apr 1996 04:00:00



Can anyone suggest a good (eg speedy) way to traverse a multi
level CTreeCtrl ?  I have two CTreeCtrl controls, where each level
contains an object type. I need to search for all objects of type X
and InsertItem() under them. The level of these object may or may
not be visible.

 X-- Level 1          - Object type A
    X-- Level 2       - Object type B
       X-- Level 3    - Object type C
 X-- Level 1          - Object type A
 ...
 ..
 .

I need to search for all object type C's and insert something
after/under them. In my first attempt I found the root object
and used the member function GetChildItem() which never returned
anything but big fat 0 for an HTREEITEM.
Can someone suggest perhaps a better method for finding all objects
of a certain type, by somehow traversing the tree ??
Any suggestions would be most appreciated.
Thanks in advance
Peter

____________________________________________________________


                                       CIS: 72274,3254
                                |||||
                               ( . . )
___________________________ooO____U____Ooo__________________

 
 
 

Traversing a CTreeCtrl ???

Post by Dr.. » Fri, 05 Apr 1996 04:00:00



>I need to search for all object type C's and insert something
>after/under them. In my first attempt I found the root object
>and used the member function GetChildItem() which never returned
>anything but big fat 0 for an HTREEITEM.

This should work; something is amiss.

Quote:>Can someone suggest perhaps a better method for finding all objects
>of a certain type, by somehow traversing the tree ??

When you insert/delete a node at the appropriate level, add/delete the
HTREEITEM in a private CPtrList. (I use a couple CMapStringToPtr
objects for fast tree lookup.)

 
 
 

Traversing a CTreeCtrl ???

Post by Peter Worcest » Sat, 06 Apr 1996 04:00:00




>>I need to search for all object type C's and insert something
>>after/under them. In my first attempt I found the root object
>>and used the member function GetChildItem() which never returned
>>anything but big fat 0 for an HTREEITEM.

>This should work; something is amiss.

>>Can someone suggest perhaps a better method for finding all objects
>>of a certain type, by somehow traversing the tree ??

>When you insert/delete a node at the appropriate level, add/delete the
>HTREEITEM in a private CPtrList. (I use a couple CMapStringToPtr
>objects for fast tree lookup.)

Thanks for the reply. I'm partly there. Your approach while OK for the current
session won't allow me to save these "maps" and then reload them. besides I
have two CTreeCtrls to go between. I am working out a 'brute force" method to
traverse the trees. Ugly but it seems to be working so far.
Thanks again for the reply.

____________________________________________________________


                                       CIS: 72274,3254
                                |||||
                               ( . . )
___________________________ooO____U____Ooo__________________

 
 
 

Traversing a CTreeCtrl ???

Post by Cleve Littlefiel » Sat, 06 Apr 1996 04:00:00



> Can anyone suggest a good (eg speedy) way to traverse a multi
> level CTreeCtrl ?

I am no expert, so do not quote me as being correct.  Have you looked at
the CTreeCursor class in MFC?  It is a little class provided to traverse
Tree Controls that so far as I know is undocumented.  It will let you
set a variable to point to a certain part of your tree and I have found
it to be invaluable.  You can find a example of it in the DaoView sample
app.

--
*********************************
*                               *
* Cleve W. Littlefield          *


*                               *
*********************************

 
 
 

1. Traversing views.

I have an MDI application with one doc template, but potentially more than
one doc/view/childframe trio running at once.  Each view has a timer that I
need to stop and start at run-time.  My question is, how do I traverse the
views and start/stop each timer at will?

Demir Ateser

2. microphone

3. Bypass Traversing Directories question...

4. ADOCE samples

5. OSX wxDir::Traverse bug??

6. MediaPlayer.CurrentPosition usage?

7. traverse hard drive and inspect filenames

8. Forms to Textfile ???

9. Traversing over subnets on NT 2 NIC's

10. Bypass Traverse Checking not working

11. wxDir::Traverse bug - OSX

12. wxDir::Traverse

13. Class for Directory tree traversing? Filespec parsing?