#include <GUIConstantsEx.au3>
#include <FileConstants.au3>
#include <GuiListBox.au3>
Local $hGUI = GUICreate("To do", 400, 400)
GUICtrlCreateLabel("текст задачи", 10, 5, 300, 20)
Local $idText = GUICtrlCreateInput("", 10, 55, 300, 20)
Local $idTask = GUICtrlCreateButton("Добавить задачу", 10, 90, 105, 25)
Local $readTask = GUICtrlCreateButton("Установить list", 160, 90, 155, 25)
Local $writeTask = GUICtrlCreateButton("Сохранить list", 10, 290, 155, 25)
GUICtrlCreateLabel("Список задач", 10, 145, 300, 20)
Local $idMylist = GUICtrlCreateList("task", 10,160, 221, 97)
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idTask
$mytask =GUICtrlRead($idText)
GUICtrlSetData($idMylist, $mytask)
Case $readTask
Local $iFileExists = FileExists("tasks.txt")
If not($iFileExists) Then
MsgBox(0, "сообщение","Файл tasks.txt не существует")
ExitLoop
EndIf
Local $hFileOpen = FileOpen("tasks.txt", $FO_READ)
While 1
$line = FileReadLine($hFileOpen)
If @error = -1 Then ExitLoop
MsgBox(0, "Line read:", $line)
GUICtrlSetData($idMylist,$line)
Wend
Case $writeTask
for $n = 0 to _GUICtrlListBox_GetCount($idMylist ) - 1
msgbox(0,"сообщение",_GUICtrlListBox_GetText( $idMylist ,$n))
next
EndSwitch
WEnd
|