version 4.00 1 Form2 Form1 2 2 0 1 0 0 0 0 1 0 0 0 2 0 0 0 1 0 0 0 238 268 C:\Documents and Settings\Home\My Documents\test2.ico 1 TreeView.dll 1 TreeView.dll 3 node1:Node node2:Node tree:TreeView Sub designer addform(Form2,"Form2","",220,220,220)@ addbutton(form2,Button2,45,185,140,23,"Choose Folder",212,208,200,0,0,0,True,True,9)@ addform(Form1,"Folder Chooser","",211,211,211)@ addcombo(form1,cmbDrives,5,5,230,22,"",255,255,255,0,0,0,True,False,0,9)@ addbutton(form1,btnSelect,135,225,75,23,"Select",212,208,200,0,0,0,True,True,9)@ addarraylist(form1,al1,155,55,80,25)@ End Sub @EndOfDesignText@Sub Globals dim root,selectedFolder End Sub Sub App_Start Form2.Show if cPPC = true then tree.new1("form1",5,5,230,200) root = "\" FindFolders("\","tree") else 'desktop tree.New1("form1",5,28,230,180) cmbDrives.Visible = true for i = asc("A") to asc("Z") if DirExist(chr(i) & ":\") = true then cmbDrives.Add(chr(i) & ":") next cmbDrives.SelectedIndex = 0 root = cmbDrives.Item(0) & "\" end if 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 tree.AddImage1(AppPath & "\folder.bmp") tree.AddImage1(AppPath & "\openFolder.bmp") End Sub Sub Button2_Click Form1.Show End Sub Sub Form1_Close s = "" node2.value = tree.selectednode do until IsNull(node2.value) = true s = node2.text & "\" & s node2.value = node2.parent loop selectedFolder = Root & s Msgbox("Selected folder:" & crlf & selectedFolder) 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 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 Sub btnSelect_Click Form1.Close End Sub Sub cmbDrives_SelectionChanged (Index, Value) tree.RemoveAllNodes root = Value & "\" FindFolders(root,"tree") End Sub