ItemID - Finding Nodes
A common problem encountered when using TreeViews is finding a node.... Say you want to keep a list of the last few nodes the user clicked, how would you do that?
Actually its relatively simple. Each node is uniquely identified by a ItemID property. The ItemID property is declared as a HTreeItem. HTreeItem is defined in CommCtrl.pas you must include this unit if you want to use HTreeItem.
There are two steps here.
Step 1: Get the Node's ItemID
iValue := integer(Node.ItemID);
Here I get the node's ItemID and save it as an integer (type-cast is needed).
Step 2: Get a Node from the ItemID
Node := TreeView.Items.GetNode( HTreeItem(iValue) );
Again a type-cast is necessary, this time from an integer to a HTreeItem.