caleb41610 Posted September 24, 2012 Share Posted September 24, 2012 (edited) #include <file.au3> #include <array.au3> #include <guiconstantsex.au3> Dim $dynamic[1000] Global $parent Global $maindrive = @HomeDrive & "\" Global $gui = GUICreate( "", 300, 400 ) GUISetState( @SW_SHOW ) Global $tree = GUICtrlCreateTreeView( 5, 5, 290, 390 ) Global $top = GUICtrlCreateTreeViewItem( $maindrive, $tree ) Func dynamiclist( $parent ) Dim $filelist = _FileListToArray( $parent ) For $i = 1 to $filelist[0] $dynamic[$i] = GUICtrlCreateTreeViewItem( $filelist[$i], $parent ) Next Return $dynamic EndFunc While 1 $msg = GUIGetMsg( ) If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $top Then dynamiclist( $maindrive ) For $i = 1 to $dynamic[$i] If $msg = $dynamic[$i] Then dynamiclist( $filelist[$i] ) EndIf Next WEnd Opened up a new file and wrote this up really quick. Trying to make a file browser that updates dynamically, not sure what's going wrong though. If I do the same thing without a function it seems to work. I think I'm writing the function itself wrong with the $parent part. Tried to write it to be use-able over and over like a UDF I suppose, but I'm new to that. Any comments/suggestions, maybe I should take a different approach? I found scarce examples when searching. Edited September 25, 2012 by caleb41610 Multi-Connection TCP Server Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2012 Moderators Share Posted September 24, 2012 caleb41610,An interesting idea. My ChooseFileFolder uses a treeview to display a tree but collects all the data at the beginning - I had not considered a dynamic tree construction. Let me play with this a while. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2012 Moderators Share Posted September 24, 2012 caleb41610, How about this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <File.au3> Global $sRoot = @ScriptDir $hGUI = GUICreate("Test", 500, 500) $cTV = GUICtrlCreateTreeView(10, 10, 480, 350) $hTV = GUICtrlGetHandle($cTV) $cRoot = GUICtrlCreateTreeViewItem($sRoot, $cTV) _Fill_Branch($cRoot, $sRoot) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case Else $cItem = GUICtrlRead($cTV) $hItem = GUICtrlGetHandle($cItem) $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), "|", "") If _GUICtrlTreeView_GetChildCount($hTV, $hItem) = -1 Then _Fill_Branch($cItem, $sSelectedPath) EndIf EndSwitch WEnd Func _Fill_Branch($cParent, $sPath) Local $aContent = _FileListToArray($sPath, "*.*", 1), $cItem If IsArray($aContent) Then For $i = 1 To $aContent[0] $cItem = GUICtrlCreateTreeViewItem($aContent[$i], $cParent) GUICtrlSetColor($cItem, 0x0000FF) Next EndIf $aContent = _FileListToArray($sPath, "*", 2) If IsArray($aContent) Then For $i = 1 To $aContent[0] $cItem = GUICtrlCreateTreeViewItem($aContent[$i] & "", $cParent) GUICtrlSetColor($cItem, 0xFF0000) Next EndIf EndFunc Any use? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AZJIO Posted September 24, 2012 Share Posted September 24, 2012 http://pastebin.com/s4LNfWVL My other projects or all Link to comment Share on other sites More sharing options...
caleb41610 Posted September 25, 2012 Author Share Posted September 25, 2012 caleb41610, How about this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <File.au3> Global $sRoot = @ScriptDir $hGUI = GUICreate("Test", 500, 500) $cTV = GUICtrlCreateTreeView(10, 10, 480, 350) $hTV = GUICtrlGetHandle($cTV) $cRoot = GUICtrlCreateTreeViewItem($sRoot, $cTV) _Fill_Branch($cRoot, $sRoot) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case Else $cItem = GUICtrlRead($cTV) $hItem = GUICtrlGetHandle($cItem) $sSelectedPath = StringReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), "|", "") If _GUICtrlTreeView_GetChildCount($hTV, $hItem) = -1 Then _Fill_Branch($cItem, $sSelectedPath) EndIf EndSwitch WEnd Func _Fill_Branch($cParent, $sPath) Local $aContent = _FileListToArray($sPath, "*.*", 1), $cItem If IsArray($aContent) Then For $i = 1 To $aContent[0] $cItem = GUICtrlCreateTreeViewItem($aContent[$i], $cParent) GUICtrlSetColor($cItem, 0x0000FF) Next EndIf $aContent = _FileListToArray($sPath, "*", 2) If IsArray($aContent) Then For $i = 1 To $aContent[0] $cItem = GUICtrlCreateTreeViewItem($aContent[$i] & "", $cParent) GUICtrlSetColor($cItem, 0xFF0000) Next EndIf EndFunc Any use? M23 Exactly what I needed! http://pastebin.com/s4LNfWVL Thanks for the input, I'm sure I can extract some knowledge from it. Multi-Connection TCP Server Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now