Hi epvp!
Damit könnt ihr GUI Inhalte (Checkbox/Radio/Input/etc.) dynamisch speichern und laden:
Beispiel:
Viel Spaß
MfG
Damit könnt ihr GUI Inhalte (Checkbox/Radio/Input/etc.) dynamisch speichern und laden:
Code:
; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlSaveState ; Description ...: Saves the state/text of gui controls ; Return values .: none ; Author ........: Achat ; Remarks .......: _GUICtrlLoadState() ; =============================================================================================================================== Func _GUICtrlSaveState() Local Const $sINI = @ScriptDir & '\GUICtrlState.ini' For $i = 0 To 4096 Local $vRead = GUICtrlRead($i) Local $vHandle = GUICtrlGetHandle($i) If Not ($vRead == 0 And $vHandle == 0) Then If IsInt($vRead) Then IniWrite($sINI, 'GuiCtrlState_CheckboxRadio', $i, StringRegExpReplace($vRead, '4', '0')) Else IniWrite($sINI, 'GuiCtrlState_Text', $i, StringToBinary($vRead)) EndIf EndIf Next Local $sRead = FileRead($sINI) If Not StringRegExp($sRead, '^;.+') Then FileDelete($sINI) FileWrite($sINI, ';Please do not modify this file.' & @CRLF & $sRead) EndIf EndFunc ;==>_GUICtrlSaveState ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlLoadState ; Description ...: Load the state/text of gui controls ; Return values .: none ; Author ........: Achat ; Remarks .......: _GuiCtrlSaveState() ; =============================================================================================================================== Func _GUICtrlLoadState() Local Const $sINI = @ScriptDir & '\GUICtrlState.ini' Local $aCheckboxRadio = IniReadSection($sINI, 'GuiCtrlState_CheckboxRadio') Local $aText = IniReadSection($sINI, 'GuiCtrlState_Text') For $i = 1 To UBound($aCheckboxRadio) - 1 GUICtrlSetState($aCheckboxRadio[$i][0], StringRegExpReplace($aCheckboxRadio[$i][1], '0', '4')) Next For $i = 1 To UBound($aText) - 1 If Not GUICtrlGetHandle($aText[$i][0]) = 0 Then GUICtrlSetData($aText[$i][0], BinaryToString($aText[$i][1])) Next EndFunc ;==>_GUICtrlLoadState
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 64, 32, 137, 41)
$Input1 = GUICtrlCreateInput("Input1", 56, 80, 185, 21)
$Button1 = GUICtrlCreateButton("Button1", 56, 120, 121, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 224, 128, 81, 33)
$Button2 = GUICtrlCreateButton("2222", 80, 248, 457, 137)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
#region ### START Koda GUI section ### Form=
$Form11 = GUICreate("Form2", 615, 438, 0, 0)
$Checkbox11 = GUICtrlCreateCheckbox("Checkbox1", 64, 32, 137, 41)
$Input11 = GUICtrlCreateInput("Input1", 56, 80, 185, 21)
$Button11 = GUICtrlCreateButton("Button1", 56, 120, 121, 17)
$Checkbox12 = GUICtrlCreateCheckbox("Checkbox2", 224, 128, 81, 33)
$Button12 = GUICtrlCreateButton("2222", 80, 248, 457, 137)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
_GUICtrlLoadState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_GUICtrlSaveState()
Exit
EndSwitch
WEnd
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlSaveState
; Description ...: Saves the state/text of gui controls
; Return values .: none
; Author ........: Achat
; Remarks .......: _GUICtrlLoadState()
; ===============================================================================================================================
Func _GUICtrlSaveState()
Local Const $sINI = @ScriptDir & '\GUICtrlState.ini'
For $i = 0 To 4096
Local $vRead = GUICtrlRead($i)
Local $vHandle = GUICtrlGetHandle($i)
If Not ($vRead == 0 And $vHandle == 0) Then
If IsInt($vRead) Then
IniWrite($sINI, 'GuiCtrlState_CheckboxRadio', $i, StringRegExpReplace($vRead, '4', '0'))
Else
IniWrite($sINI, 'GuiCtrlState_Text', $i, StringToBinary($vRead))
EndIf
EndIf
Next
Local $sRead = FileRead($sINI)
If Not StringRegExp($sRead, '^;.+') Then
FileDelete($sINI)
FileWrite($sINI, ';Please do not modify this file.' & @CRLF & $sRead)
EndIf
EndFunc ;==>_GUICtrlSaveState
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlLoadState
; Description ...: Load the state/text of gui controls
; Return values .: none
; Author ........: Achat
; Remarks .......: _GuiCtrlSaveState()
; ===============================================================================================================================
Func _GUICtrlLoadState()
Local Const $sINI = @ScriptDir & '\GUICtrlState.ini'
Local $aCheckboxRadio = IniReadSection($sINI, 'GuiCtrlState_CheckboxRadio')
Local $aText = IniReadSection($sINI, 'GuiCtrlState_Text')
For $i = 1 To UBound($aCheckboxRadio) - 1
GUICtrlSetState($aCheckboxRadio[$i][0], StringRegExpReplace($aCheckboxRadio[$i][1], '0', '4'))
Next
For $i = 1 To UBound($aText) - 1
If Not GUICtrlGetHandle($aText[$i][0]) = 0 Then GUICtrlSetData($aText[$i][0], BinaryToString($aText[$i][1]))
Next
EndFunc ;==>_GUICtrlLoadState
MfG