'FolderChooser is an example of using the TreeView library.
'The folder nodes are added the first time the user presses on a folder.
Sub Globals
Dim root
End Sub
Sub App_Start
If cPPC=True Then root="\" Else root = SubString(AppPath,0,3)
Form1.show
tree.new1("form1",5,5,230,200)
tree.AddImage1(AppPath & "\folder.bmp")
tree.AddImage1(AppPath & "\openFolder.bmp")
tree.ImageMode = True
tree.ImageIndex = 0 'sets all nodes to display the folder icon
tree.SelectedImageIndex = 1 'sets the selcted node (each time) to display the open folder icon
node1.new1
node2.new1
FindFolders("\","tree")
End Sub
Sub FindFolders (path, node) 'Finds all folders in a specific path
WaitCursor(True)
al1.clear
DirSearch(al1,path)
c = StrLength(path)
For I =0 To al1.count - 1
s=al1.item(i)
If node = "tree" Then
tree.AddNewNode(SubString(s,c,StrLength(s)-c))
Else
Control(node,Node).AddNewNode (SubString(s,c,StrLength(s)-c))
End If
Next
If node = "tree" Then
tree.ExpandAll
Else
Control(node,Node).Expand
End If
WaitCursor(False)
End Sub
Sub tree_AfterSelect
If tree.action <> "bymouse" Then Return 'If the event was not raised by the user
'When the user presses on a node, search for all folders inside.
node2.value = tree.selectednode
node1.value = tree.selectednode
Dim s
If node2.count = 0 Then 'If it is not 0 then the it was already opened
Do Until IsNull(node2.Value) = True 'Find the full path of the current node
s = node2.text & "\" & s
node2.value = node2.parent
Loop
FindFolders(root & s,"node1")
End If
End Sub