Jump to content

Need help with checkbox


Recommended Posts

I've created a simple checkbox..My problem is how do I iniwrite the value to a inifile so that I dont have to check the box everytime I re-run the script?

CODE
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("AForm1", 130, 82, 193, 115)

$Checkbox1 = GUICtrlCreateCheckbox("Sample", 32, 40, 65, 17)

$Group1 = GUICtrlCreateGroup("SampleBox", 0, 0, 129, 81)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

;iniread here..

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Iniwrite("settings.ini", "Primary", "Sample", Bitand(GUICtrlRead($Checkbox1 ),$GUI_CHECKED) = $GUI_CHECKED ; This is wrong..pls help

Exit

EndSwitch

WEnd

I'm new and I just want to learn.. I go through the help files but it doest say that how to store value of checkbox

(checked/uncheck) into an ini file. Thank you

Link to comment
Share on other sites

Also writing:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 130, 82, 193, 115)
$Checkbox1 = GUICtrlCreateCheckbox("Sample", 32, 40, 65, 17)
$Group1 = GUICtrlCreateGroup("SampleBox", 0, 0, 129, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$value1 = IniRead('settings.ini', "Primary", "Sample", "0")
If $value1 = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED)
    
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If Bitand(GUICtrlRead($Checkbox1 ),$GUI_CHECKED) = $GUI_CHECKED Then
                $value1 = "1"
            Else
                $value1 = "0"
            EndIf
            Iniwrite("settings.ini", "Primary", "Sample", $value1)
            Exit
    EndSwitch
WEnd

INI content:

[Primary]
Sample=1
Edited by Zedna
Link to comment
Share on other sites

$checkbox1 = IniRead('name.ini', "Values", "Sample1", "0")
If $checkbox1 = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED)

Zedna...I'll give you some time to rethink that one :P

At first look I didn't noticed his IniWrite attempt with names of INI, options so I write some names from my head.

In my second post it's correct.

EDIT: you are right I was using control variable also for it's value :">

Edited by Zedna
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...