Searching a treeview control

From: Developer (wanderer_at_mapinfo.nope.com)
Date: 02/02/05


Date: Wed, 2 Feb 2005 11:59:35 -0500

Hello,

I'm working in C, Win32 SDK (legacy app...)

I'm trying to populate a treeview to show a heirarchy. I retrieve nodes
from a db. Each node has a name and a parent's name; I want to search the
tree to find the parent to attach the node to.

My problem is in searching the tree. I'm trying to walk the tree
recursively, searching for the correct node.
Here's the heart of my traversal:
  // Check this node for children
  hChild = TreeView_GetChild(hWnd, hCurrent);

  if (hChild) {
   returnPtr = FindTreeNode(winDlg, idCtl, hChild, nodeText);
  }
  else {
   // No children. Does the current node have any siblings?
   hSib = hCurrent;
   while (hSib && returnPtr == 0) {
    hSib = TreeView_GetNextSibling(hWnd, hSib);
    returnPtr = FindTreeNode(winDlg, idCtl, hSib, nodeText);
   }
  }

hCurrent is the node passed in to the function.
I'm not certain about the behavior of TreeView_GetNextSibling. Should it be
    hSib = TreeView_GetNextSibling(hWnd, hSib);
or
    hSib = TreeView_GetNextSibling(hWnd, hCurrent);

Thanks for any advice...



Relevant Pages

  • Re: Locality of allocations
    ... of more cpu cycles to avoid paging. ... do some simple data compression on these (are they mostly ... Is this tree used for searching? ...
    (comp.os.linux.development.apps)
  • Re: How long would it take a computer to completely "solve" chess?
    ... >> a rook against a king, search one ply farther to rule out stalemate ... >> and stop searching that branch. ... the tree will get to the same position (with same ... A position that has a known algorithm for winning. ...
    (sci.math)
  • Re: Smart Deleting
    ... You have a tree that you need to traverse to its root (highest ... subject in the various Access & SQL newsgroups. ... Try searching newsgroups: ...
    (microsoft.public.access.queries)
  • Re: Data structure for indexing on multiple keys.
    ... >> Please note that this is not about composite keys but supporting ... >>multiple keys for searching. ... > k-d Tree ... > P-Tree ...
    (comp.theory)
  • Re: Data structure for indexing on multiple keys.
    ... >> Please note that this is not about composite keys but supporting ... >>multiple keys for searching. ... > k-d Tree ... > P-Tree ...
    (comp.programming)

Quantcast