Что нового

как добиться Автообновления списка?

lexaSF

Новичок
Сообщения
182
Репутация
3
Автообновление списка готово, но отсалась 1 проблема - в список добавляются все секции из Inireadsection(), но если добавить новый аккаунт, строке в List1 не появляется, подскажите как решить эту проблему с постоянным обновлением списка!
У меня есть идея, можно ли как нибудь сразу переместиться на другой уровент For Next?
Код:
#include <GUIConstants.au3>
#Include <GuiComboBox.au3>
#Include <GuiListBox.au3>
#Include <File.au3>
#Include <Array.au3>

$Dir = @DesktopDir & '\ini.ini'
$FileList=_FileListToArray(@ScriptDir & '\settings')

#Region ### START Koda GUI section ### Form=
$Form1_1_1 = GUICreate("Form1", 376, 322, 370, 266)
GUISetIcon("C:\Users\Lexa\Desktop\heroic_autobots.ico")
GUISetBkColor(0xB9D1EA)
$Label1 = GUICtrlCreateLabel("SID", 16, 128, 35, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Input1 = GUICtrlCreateInput("", 16, 56, 169, 21)
$Label2 = GUICtrlCreateLabel("Name", 16, 32, 50, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Input2 = GUICtrlCreateInput("", 16, 152, 169, 21)
$Label3 = GUICtrlCreateLabel("ID", 16, 80, 23, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Input3 = GUICtrlCreateInput("", 16, 104, 169, 21)
$Label4 = GUICtrlCreateLabel("Server", 16, 176, 56, 24)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Input4 = GUICtrlCreateInput("", 16, 200, 169, 21)
$Button1 = GUICtrlCreateButton("Save", 16, 280, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button2 = GUICtrlCreateButton("Delete", 208, 280, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$List1 = GUICtrlCreateList("", 208, 104, 153, 162)
$Button3 = GUICtrlCreateButton("Clear", 112, 280, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button4 = GUICtrlCreateButton("Edit", 289, 280, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Label5 = GUICtrlCreateLabel("  Load Settings", 224, 0, 122, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Constantia")
$Combo1 = GUICtrlCreateCombo("None", 208, 56, 153, 25)
For $K=1 To $FileList[0]
	_GUICtrlComboBox_AddString($Combo1,$FileList[$k])
Next
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Combo2 = GUICtrlCreateCombo("None", 16, 248, 169, 25)
GUICtrlSetData(-1, "1-1|1-2|1-3|1-4|1-5|1-6|1-7|1-8|2-1|2-2|2-3|2-4|2-5|2-6|2-7|2-8|3-1|3-2|3-3|3-4|3-5|3-6|3-7|3-8|4-1|4-2|4-3|4-5")
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Label6 = GUICtrlCreateLabel("Account", 72, 0, 67, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Constantia")
$Label7 = GUICtrlCreateLabel("Map", 16, 224, 32, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
	$read = IniReadSectionNames($Dir)
    If @error <> 1 Then
For $i=1 To $read[0] ; вот здесь добавляются строки
    $FindStr = _GUICtrlListBox_FindString($List1,$read[$i])
    $FindText = _GUICtrlListBox_GetText($List1,$FindStr) ; $findText = 0 здесь
	$IsNumber = IsNumber($FindText)
    If $IsNumber = 0 And $FindText = $read[$i] Then 
     ExitLoop       
     Else
_GUICtrlListBox_AddString($List1, $read[$i])
        EndIf
    Next 
EndIf
$name = GUICtrlRead($Input1)
$sid = GUICtrlRead($Input2)
$id = GUICtrlRead($Input3)
$serv = GUICtrlRead($Input4)
$map = GUICtrlRead($Combo2)
$Setting = ControlGetText('Form1','','[CLASS:Edit; INSTANCE:5]')
$Findname = _GUICtrlListBox_FindString($List1,$name)
$FindTextname = _GUICtrlListBox_GetText($List1,$Findname)
	$nMsg = GUIGetMsg()
	Switch $nMsg
	Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			IniWrite( $Dir,$name, "SID",$sid)
			IniWrite( $Dir,$name, "ID",$id)
			IniWrite( $Dir,$name, "SERVER",$serv)
			IniWrite( $Dir,$name, "MAP",_GUICtrlComboBox_GetCurSel($Combo2))
			IniWrite( $Dir,$name, "SETTING",$Setting)
			If $name = $FindTextname And IsNumber($FindTextname) = 0 Then
				MsgBox(0,'OK!','Account Edit!')
			Else
			MsgBox(0,'OK!','Account Save!')
			EndIf
		Case $Button2
			$Marker = _GUICtrlListBox_GetCaretIndex($List1)
			$StrText = _GUICtrlListBox_GetText($List1,$Marker)
			_GUICtrlListBox_DeleteString($List1, $Marker)
			IniDelete($Dir,$StrText)
		EndSwitch
WEnd
 
Верх