#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
GUICreate("", 500,500)
Local $idTreeview = GUICtrlCreateTreeView(6, 6, 140, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $idGeneralitem = GUICtrlCreateTreeViewItem("Дерево файлов", $idTreeview)
GUICtrlSetColor(-1, 0x0000C0)
Local $hFile= FileOpen("files.txt", $FO_READ)
While 1
$sLine = FileReadLine($hFile)
If @error = -1 Then ExitLoop
GUICtrlCreateTreeViewItem($sLine,$idGeneralitem)
WEnd
FileClose($hFile)
Local $idbutton = GUICtrlCreateButton("открыть", 175, 185, 70, 20)
Local $idtextinput = GUICtrlCreateEdit("", 150, 5, 300, 150)
GUISetState(@SW_SHOW)
While 1
$idMsg = GUIGetMsg()
if ($idMsg = $GUI_EVENT_CLOSE) Then
ExitLoop
Endif
if $idMsg = $idbutton then
$idItem = GUICtrlRead($idTreeview)
$filename = GUICtrlRead($idItem ,1)
if FileExists($filename) then
$hFile = FileOpen($filename, $FO_READ)
$text = FileRead($hFile,FileGetSize($filename))
FileClose($hFile)
GUICtrlSetData($idtextinput,$text)
Else
MsgBox(0,"сообщение","такого файла не существует")
EndIf
EndIf
WEnd
|