version 5.80 0 Form1 1 1 0 0 0 0 0 0 2 0 0 1 2 0 0 0 1 0 0 0 238 268 1 TreeView.dll 1 TreeView.dll 3 node1:Node node2:Node tree:TreeView Sub designer addform(Form1,"Folder Chooser","",211,211,211)@ addlistbox(form1,ListBox1,10,215,140,50,"",255,255,255,0,0,0,True,True,0,9)@ addbutton(form1,btnSelect,155,215,75,23,"Select",212,208,200,0,0,0,True,True,9)@ addarraylist(form1,al1,155,20,80,25)@ End Sub @EndOfDesignText@'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 FolderPath="" 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) Control(node).addnewnode (SubString(s,c,StrLength(s)-c)) Next Control(node).expand 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 SelectFolder End Sub Sub SelectFolder node2.value = tree.selectednode Do Until IsNull(node2.value) = true s = node2.text & "\" & s node2.value = node2.parent Loop FolderPath=Root & s FindFiles End Sub Sub FindFiles 'Finds all files in a specific path WaitCursor(true) ListBox1.Clear al1.clear FileSearch(al1,FolderPath) For i =0 To al1.count - 1 s=al1.item(i) ListBox1.Add(FileName(s)) Next WaitCursor(false) End Sub Sub btnSelect_Click Msgbox(FolderPath&ListBox1.Item(ListBox1.SelectedIndex)) End Sub