回复 1# showshow
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <File.au3>
;~ #include <Array.au3>
$Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
Local $hItem[10], $hTreeView
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
GUICreate("TreeView Set Icon", 400, 500)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 388, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
_FindFile('c:')
_GUICtrlTreeView_EndUpdate($hTreeView)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func _FindFile($sPath)
$aFileList = _FileListToArray($sPath)
If Not @error Then
For $i = 1 To $aFileList[0] - 1
$tm = GUICtrlCreateTreeViewItem($aFileList[$i], $hTreeView)
If StringInStr(FileGetAttrib($sPath & '\' & $aFileList[$i]), "D") Then
$DDD = _FileListToArray($sPath & '\' & $aFileList[$i])
If Not @error Then
For $s = 1 To $DDD[0] - 1
$m = GUICtrlCreateTreeViewItem($DDD[$s], $tm)
Next
EndIf
EndIf
Next
EndIf
EndFunc ;==>_FindFile
|