Sign in to follow this  
Followers 0
mini

[SOLVE] Help with CheckBox

5 posts in this topic

#1 ·  Posted (edited)

Hey all.

Im playing with some check box's, and saving them on a .INI file.

All work perfect except one part that I'm not managing to solve my problem.

Problem:

If I make my GUI read and if i don't have no .INI file or if i don't have no Information for the check box's, they are automatically Tick.

Here's my code, hope that someone knows how to solve this little problem.

Thanks in advance.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("CheckBox Test", 413, 305)
$Save = GUICtrlCreateButton("&Save", 56, 240, 75, 25)
$Read = GUICtrlCreateButton("&Read", 154, 240, 75, 25)
$Reset = GUICtrlCreateButton("&Reset", 254, 240, 75, 25)
$Delete = GUICtrlCreateButton("&Delete", 254, 200, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;Local $SNVCheckBoxMH, $previewcheckbox, $msg

$SNVCheckBoxMH = GUICtrlCreateCheckbox("&MH", 50, 60, 14, 20)
GUICtrlCreateLabel("MH",65,63,40,20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$previewcheckbox = GUICtrlCreateCheckbox("&Play result", 50,100,100,100)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    case -3
        _Check4CLOSEClicked()
        Case $Save
            _Save()
        Case $Read
            _Read()
        Case $Reset
            _Reset()
        Case $Delete
            _Delete()
    EndSwitch
WEnd

func _Save()
            $answer = MsgBox(36, "Warning", "Save data?", 8 )
        If $answer = 6 Then
    IniWrite("test.ini", "config", "$SNVCheckBoxMH", GUICtrlRead($SNVCheckBoxMH))
    IniWrite("test.ini", "config", "$previewcheckbox", GUICtrlRead($previewcheckbox))
    EndIf
EndFunc

func _Read()
    GUICtrlSetState($previewcheckbox, IniRead("test.ini", "config", "$previewcheckbox", $previewcheckbox))
    GUICtrlSetState($SNVCheckBoxMH, IniRead("test.ini", "config", "$SNVCheckBoxMH", $SNVCheckBoxMH))
EndFunc

Func _Reset()
            $answer = MsgBox(36, "Warning", "Reset?", 8 )
        If $answer = 6 Then
GUICtrlSetState($previewcheckbox, "4")
GUICtrlSetState($SNVCheckBoxMH, "4")
EndIf
EndFunc

Func _Delete();Delete the Client INI file
    $answer = MsgBox(36, "Warning", "You will Delete the test.ini file from Dir?", 8 )
If $answer = 6 Then
    ;<=================>;
FileDelete("test.ini")
    ;<=================>;
EndIf   
    EndFunc
Func _Check4CLOSEClicked();Exit
        $answer = MsgBox(36, "Warning", "Exit?", 8 )
        If $answer = 6 Then
            EndIf
    Exit
EndFunc
Edited by mini

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Maybe you should change that weird default value;

IniRead("test.ini", "config", "$previewcheckbox", $previewcheckbox)

You do know what the fourth parameter is for, right?

No mate, I've been removing from some made GUI's all the information.

Sow, there are somethings that i don't understand or even don't know, but for your question, I see that I'm making a big mistake.

Can you clarify me on the 4 Parameter's please!! :mellow:

Edit: Ok, i think i found what i made wrong, 4th Parameter = Default, sow, the Default value for the Check Box to be "blank" is 4, sow i just Change the 4th parameter to "4" and its working well...

Thans very much for the ear push. :(:lol:

Edited by mini

Share this post


Link to post
Share on other sites

Can you clarify me on the 4 Parameter's please!! :mellow:

Did you not read the IniRead documentation :(?

Share this post


Link to post
Share on other sites

Did you not read the IniRead documentation :lol:?

Yes, went there after replaying :mellow::(

Heres the Full Working program

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("CheckBox Test", 413, 305)
$Save = GUICtrlCreateButton("&Save", 56, 240, 75, 25)
$Read = GUICtrlCreateButton("&Read", 154, 240, 75, 25)
$Reset = GUICtrlCreateButton("&Reset", 254, 240, 75, 25)
$Delete = GUICtrlCreateButton("&Delete", 254, 200, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;Local $SNVCheckBoxMH, $previewcheckbox, $msg

$SNVCheckBoxMH = GUICtrlCreateCheckbox("&MH", 50, 60, 14, 20)
GUICtrlCreateLabel("MH",65,63,40,20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$previewcheckbox = GUICtrlCreateCheckbox("&Play result", 50,100,100,100)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    case -3
        _Check4CLOSEClicked()
        Case $Save
            _Save()
        Case $Read
            _Read()
        Case $Reset
            _Reset()
        Case $Delete
            _Delete()
    EndSwitch
WEnd

func _Save()
            $answer = MsgBox(36, "Warning", "Save data?", 8 )
        If $answer = 6 Then
    IniWrite("test.ini", "config", "$SNVCheckBoxMH", GUICtrlRead($SNVCheckBoxMH))
    IniWrite("test.ini", "config", "$previewcheckbox", GUICtrlRead($previewcheckbox))
    EndIf
EndFunc

func _Read()
    GUICtrlSetState($previewcheckbox, IniRead("test.ini", "config", "$previewcheckbox", "4"))
    GUICtrlSetState($SNVCheckBoxMH, IniRead("test.ini", "config", "$SNVCheckBoxMH", "4"))
EndFunc

Func _Reset()
            $answer = MsgBox(36, "Warning", "Reset?", 8 )
        If $answer = 6 Then
GUICtrlSetState($previewcheckbox, "4")
GUICtrlSetState($SNVCheckBoxMH, "4")
EndIf
EndFunc

Func _Delete();Delete the Client INI file
    $answer = MsgBox(36, "Warning", "You will Delete the test.ini file from Dir?", 8 )
If $answer = 6 Then
    ;<=================>;
FileDelete("test.ini")
    ;<=================>;
EndIf   
    EndFunc
Func _Check4CLOSEClicked();Exit
        $answer = MsgBox(36, "Warning", "Exit?", 8 )
        If $answer = 6 Then
            EndIf
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0