Sign in to follow this  
Followers 0
jinyue115

*** Recursion the treeview ***

3 posts in this topic

what 's the break point in below Recursion function ?

how use the Recursion function to finish Recursive traversal ?

Thanks for your reading !

#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <file.au3>
#include <array.au3>

Global $filepath, $hitem, $path, $i, $j, $filelist, $filelistb
$path = @DesktopDir & '\test\'

$GUI = GUICreate("(UDF Created) TreeView Create", 400, 640)

$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 568);,$iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
;==========================================================================
TreeViewList($path)
;==========================================================================
_GUICtrlTreeView_EndUpdate($hTreeView)

GUISetState()
Do
Until GUIGetMsg() = -3

Func TreeViewList($path)
;~ While 1
    $filelist = _FileListToArray($path)
    If @error = 1  then Exit
    If UBound($filelist) <> '' Then
        For $i = 1 To $filelist[0]
            $hitem = _GUICtrlTreeView_Add($hTreeView, 0, $filelist[$i])
            $filepath = $path & '\' & $filelist[$i]
;===========================================================================================
            $filelistb = _FileListToArray($filepath)
            If @error = 1 Then Exit
            If UBound($filelistb) <> '' Then
                For $j = 1 To $filelistb[0]
                    $hitemb = _GUICtrlTreeView_AddChild($hTreeView, $hitem, $filelistb[$j])
                    $filepath = $path & '\' & $filelist[$i] & '\' & $filelistb[$j]
                    ;~              Recursion($filepath, $hitemb)
;==========================================================================                 
                    $filelistc = _FileListToArray($filepath)
                    If @error = 1 Then Exit
                    If UBound($filelistc) <> '' Then
                        For $k = 1 To $filelistc[0]
                            $hitemc = _GUICtrlTreeView_AddChild($hTreeView,$hitemb,$filelistc[$k])
                            $filepath = $path & '\' & $filelist[$i] & '\' & $filelistb[$j] & '\' & $filelistc[$k]
                        Next
                    EndIf
;==========================================================================                 
                Next
            EndIf
;=============================================================================================          
;~          digui($filepath, $hitem)
        Next
    EndIf
;~ WEnd
EndFunc   ;==>TreeViewList

Func Recursion($filepath, $hitem)
    $filelistb = _FileListToArray($filepath)
    If @error = 1 Then Exit
    If UBound($filelistb) <> '' Then
        For $j = 1 To $filelistb[0]
                $hitemb = _GUICtrlTreeView_AddChild($hTreeView, $hitem, $filelistb[$j])
                $filepath = $path & '\' & $filelist[$i] & '\' & $filelistb[$j]
;~              Recursion($filepath, $hitemb)
        Next
    EndIf
EndFunc   ;==>Recursion

Share this post


Link to post
Share on other sites



recursion fuction does not work

Share this post


Link to post
Share on other sites

jinyue115,

Please do not bump your posts within 24 hours. :x

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually - like this. :P

There are plenty of recursive file searches on the forum - my version is in my sig (RecFileListToArray). I suggest you take a look at them to see how other coders have dealt with the recursion problem - I avoided it altogether by using a separate array! :shifty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0