PDA

View Full Version : Enhanced TreeView functionality + Class


tuc
06-07-2007, 02:04 AM
Hi
Whilst working with the TreeView interface via SWAPI, I realised that it did not meet my needs as it is currently implemented. In particular the lack of "lParam" support. The "lParam" allows you to stored an integer for each node in the treeview, which is a far better reference item that the text name.

I decided to write a small class as an experiment to resolve this and at the same time also added some extra functionality, in particular the "walk" function. Which will traverse the entire tree from the starting node including all sub-nodes/children. The standard Next/Prev functions in SWAPI and my TreeClass only interate over the nodes at the same level within the tree.

I have tried to comment the code and have provided a small demo program to show its functionality.
I have also implemented "Find" methods as well.

Please feel free to use and abuse and any comments / updates or recommendations are always welcome.

As you will see in the TreeView.pll file, I have borrowed heavily on the existing code from SWAPI. No point in re-inventing the wheel totally.

Until SWAPI includes some of this functionality in a future release, this class fills in some of the gaps.

Note.
When the class is instantiated, the handle of the treeview component of passed to the class and maintained internally. No further reference to the original treeview handle is required.

You can freely interchange between the TreeView class and the standard SWAPI functions at any time.

Tuc
Long live PPL[br]1181178251_117_FT0_tv.zip

kornalius
06-07-2007, 05:32 PM
Thank you for sharing with us your wisdom.

We have updated our SWAPI.PPL library to support the lParam$ in TreeView and ListView.

kornalius
06-07-2007, 05:37 PM
It looks like there is a bug in Root, PrevItem, NextItem, Parent, Child functions:

Shouldn't the return variable be Item$ and not hItem$ ?

tuc
06-08-2007, 01:01 AM
Alain
Not actually, each of those functions calls the SetSelected method, and this sets the class variable hItem$, and this is returned, as in some cases the node may not change (item$ == 0).
I suppose this does leave open the issue of iterating over a branch and not knowing when you are at the end though, unless you compare old/new nodes

Tuc