IWAdvTreeView

HELP!!!

I need help trying to search the nodes of the tree component.  I got partial help a couple of days ago, but the sample code provided was not right.  In the standard treeview component the ALL of nodes exist in an array, which makes searching the whole thing very easy.  Your nodes are in a linked list.

I know I have to use recursion, but I cannot make it work.  I keep getting stack overflow errors.  I tried to use the sample code (listed at the end), but it had no calls to GetNextChild.  How can it work without calling that routine?  I tried to make sense of it, but was only able to make it work one level deep.

I know this is outside the normal scope of support, but I do not know where else to get help.  I need a function that will find a node by matching its Tag value.  When I load the tree data I set the Tag value to the RecordID of the node being added.  If a new node has a parent node, I need to call a function with the parent node ID that either returns the node or nil.  Is any of that even possible?

Here is what I was given to work from:

    N: TAdvTreeNode;
    N := TIWAdvTreeView1.Items.GetFirstNode;
    while (N <> nil) do
    begin
      RetrieveChildNodes(N);
      N := N.getNextSibling;
    end;


function RetrieveChildNodes(Node: TAdvTreeNode): string;
var  ExN: TAdvTreeNode;
begin
  if not Assigned(Node) then
    Exit;

  ExN := Node.getFirstChild;
  if Assigned(ExN) then
  begin
    while (ExN <> nil) do
    begin
       OutputDebugString(pchar('item tag: ' + IntToStr(ExN.Tag)));
        RetrieveChildNodes(ExN);
        ExN := ExN.getNextSibling;
    end;
  end;
end;

Please have a look at my reply in your previous Topic.

http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=157&PID=579&title=tiwadvtreeview-examples#579