hab mal noch was in meiner Script Sammlung gefunden. hab aber heute wenig zeit das mal zu prüfen.
AutoIt
#include <GuiTreeView.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
Global $bgcolor = 0x404040, $txtcolor = 0xff8800, $extcolor = 0xffcc00, $items[4000], $names[4000], $StartDir, $TreevieItemNow, $wParam
$StartDir = "D:\Test"
$hGui = GUICreate("Treeview_Test", 800, 600, -1, -1)
$hTreeView = _GUICtrlTreeView_Create($hGui, 2, 2, 180, 600)
$hTreeView_First = _GUICtrlTreeView_AddChild($hTreeView,"","Projekte")
_GUICtrlTreeView_BeginUpdate($hTreeView)
ListFiles_ToTreeView($StartDir, 0)
_GUICtrlTreeView_EndUpdate($hTreeView)
_GUICtrlTreeView_Expand($hTreeView)
GUISetState(@SW_SHOW)
;~ While 1
;~ $msg = GUIGetMsg()
;~ Switch $msg
;~ Case $GUI_EVENT_CLOSE
;~ Exit
;~ Case Else
;~ If $msg >= $items[2] And $msg <= $items[UBound($items) - 1] Then ishidden(_GUICtrlTreeView_GetTree($hTreeView, "\"))
;~ Sleep(20)
;~ GUICtrlSetState($names, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold
;~ EndSwitch
;~ WEnd
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func ListFiles_ToTreeView($sSourceFolder, $hItem)
Local $sFile
; Force a trailing \
If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\"
; Start the search
Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*")
; If no files found then return
If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<
; Now run through the contents of the folder
While 1
; Get next match
$sFile = FileFindNextFile($hSearch)
; If no more files then close search handle and return
If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<
; Check if a folder
If @extended Then
; If so then call the function recursively
ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile))
Else
; If a file than write path and name
_GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)
EndIf
WEnd
; Close search handle
FileClose($hSearch)
EndFunc ;==>ListFiles_ToTreeView
;~ Func ishidden($file)
;~ Local $attrib
;~ $attrib = FileGetAttrib($file)
;~ MsgBox(0, "", $file & @CRLF & "Properties: " & $attrib)
;~ If StringInStr($attrib, "H") Then Return 1
;~ Return 0
;~ EndFunc ;==>ishidden
Alles anzeigen
Gruß gmmg