#include <GUITreeView.au3>
$hGUI = GUICreate("Test", 400, 300)
$hTreeView = _GUICtrlTreeView_Create($hGUI, 5, 5, 390, 290, BitOR($TVS_HASLINES, $TVS_SHOWSELALWAYS, $TVS_HASBUTTONS, $TVS_LINESATROOT), 512)
$iTimer = TimerInit()
_AddTreeViewItem($hTreeView, @ScriptDir & "\Dirs.txt")
MsgBox(0, TimerDiff($iTimer), "")
_GUICtrlTreeView_Expand($hTreeView)
GUISetState()
While GUIGetMsg() + 3
WEnd
Func _AddTreeViewItem($hTreeView, $sFilePath)
Local $hFile, $iLine, $sText, $aText, $sCurrent, $sParent
$hFile = FileOpen($sFilePath)
If $hFile < 1 Then Return SetError(1, 0, 0)
While 1
$iLine += 1
$sText = FileReadLine($hFile, $iLine)
If @error Then ExitLoop
$sCurrent = ""
$sParent = ""
$aText = StringSplit($sText, "\")
For $i = 1 To $aText[0]
$sCurrent &= $aText[$i] & "\"
If Not IsDeclared($sCurrent) Then
Assign($sCurrent, _GUICtrlTreeView_AddChild($hTreeView, Eval($sParent), $aText[$i]))
EndIf
$sParent = $sCurrent
Next
WEnd
FileClose($hFile)
Return $iLine > 0
EndFunc ;==>_AddTreeViewItem
|