DoEnumerateTree - AbstractTreeView
Recurses the items in the control starting with the item you pass, hItem
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| iMsg | Integer | The message whose message-id you pass |
| hItem | Handle | The item you pass |
| iRecurseLevel | Integer | The starting level as you want to identify it |
Syntax
Procedure DoEnumerateTree Integer iMsg Handle hItem Integer iRecurseLevel
Call Example
Send DoEnumerateTree iMsg hItem iRecurseLevel
Description
DoEnumerateTree is an advanced procudure. It recurses the items in the control starting with the item you pass, hItem. The procedure will traverse all items that are children of the item you pass. It will find the first child and look for its children and its siblings and so on until all child items have been found. For each item that is found, it will send a message to the message whose message-id you pass as the iMsg parameter. You would normally pass zero as the iRecurseLevel, as this represents the starting level as you want to identify it. You can pass any value you want, and it will be incremented for each level of recursion and passed on to the message you have defined. The procedure whose message ID you pass, should take two parameters: a Handle to hold the handle of the item found, and an Integer to hold the recurse level of the item, which will be relative to iRecurseLevel.
This procedure is used internally, but is not defined as Private, as there may be times when it will be very useful.
Sample
This sample shows how to enumerate a tree starting at the root item. Procedure CompareTreeItem is called for each tree item to compare if the search value is in the tree item label. The compare is case sensitive. If the match is found, the label and the tree item handle are stored in the search results property declared above.
tDataSourceRow is only used as a convenience. This sample originated from a view where the results were then used to see a cCJGrid. You could store the results in any array of structs that includes a String and a Handle element.
Property tDataSourceRow[] pSearchResults
Procedure CompareTreeItem Handle hItem Integer iLevel
String sText sSearchValue
tDataSourceRow[] SearchResults
Integer iElement
Get Value of oSearchForm to sSearchValue
Get ItemLabel hItem to sText
If (sText contains sSearchValue) Begin
Get pSearchResults to SearchResults
Move (SizeOfArray (SearchResults)) to iElement
Move sText to SearchResults[iElement].sValue[2]
Move hItem to SearchResults[iElement].sValue[1]
Set pSearchResults to SearchResults
End
End_Procedure
Procedure SearchInTree
Handle hRoot
tDataSourceRow[] SearchResults
Get RootItem to hRoot
Set pSearchResults to SearchResults
Send DoEnumerateTree (RefProc (CompareTreeItem)) hRoot 0
Get pSearchResults to SearchResults
// now do whatever you want with the results
End_Procedure
See Also