Jump to content
def456

Save Checkbox,Radio state

Recommended Posts

def456

Hi,

I want  when Gui open, read the state of Checkbox and Radio and GuiCtrlSetState it

When button close clicked, I want to save state of Checkbox and Radio

what should I use to save it?

Here is my code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate(" ", 242, 139, Default, Default)


$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17)

$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17)

$Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25)

$Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25)



GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
   Case $GUI_EVENT_CLOSE
      Exit

    EndSwitch
WEnd

Can you help me fixing it ? Thanks :)

Share this post


Link to post
Share on other sites
Melba23

def456,

Welcome to the AutoIt forum.

But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "Do not post general support questions here".  I have moved it for you, but would ask you to be more careful in future.

M23

 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
def456
11 hours ago, Melba23 said:

def456,

Welcome to the AutoIt forum.

But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "Do not post general support questions here".  I have moved it for you, but would ask you to be more careful in future.

M23

 

I'm sorry, I will more carefully in the future. Thanks for remind me.

 

Share this post


Link to post
Share on other sites
Subz
Posted (edited)

Here is one way, using Ini to save config settings.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $sConfig = @ScriptDir & "\Config.ini"

GUICreate(" ", 242, 139, Default, Default)
    Local $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17)
        GUICtrlSetState($Checkbox1, IniRead($sConfig, "Config", "Checkbox1", 4))
    Local $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17)
        GUICtrlSetState($Checkbox2, IniRead($sConfig, "Config", "Checkbox2", 4))
    Local $Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25)
        GUICtrlSetState($Radio1, IniRead($sConfig, "Config", "Radio1", 4))
    Local $Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25)
        GUICtrlSetState($Radio2, IniRead($sConfig, "Config", "Radio2", 4))
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            IniWrite($sConfig, "Config", "Checkbox1", GUICtrlRead($Checkbox1))
            IniWrite($sConfig, "Config", "Checkbox2", GUICtrlRead($Checkbox2))
            IniWrite($sConfig, "Config", "Radio1", GUICtrlRead($Radio1))
            IniWrite($sConfig, "Config", "Radio2", GUICtrlRead($Radio2))
            Exit
    EndSwitch
WEnd

 

Edited by Subz

Share this post


Link to post
Share on other sites
def456
4 hours ago, Subz said:

Here is one way, using Ini to save config settings.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $sConfig = @ScriptDir & "\Config.ini"

GUICreate(" ", 242, 139, Default, Default)
    Local $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17)
        GUICtrlSetState($Checkbox1, IniRead($sConfig, "Config", "Checkbox1", 4))
    Local $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17)
        GUICtrlSetState($Checkbox2, IniRead($sConfig, "Config", "Checkbox2", 4))
    Local $Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25)
        GUICtrlSetState($Radio1, IniRead($sConfig, "Config", "Radio1", 4))
    Local $Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25)
        GUICtrlSetState($Radio2, IniRead($sConfig, "Config", "Radio2", 4))
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            IniWrite($sConfig, "Config", "Checkbox1", GUICtrlRead($Checkbox1))
            IniWrite($sConfig, "Config", "Checkbox2", GUICtrlRead($Checkbox2))
            IniWrite($sConfig, "Config", "Radio1", GUICtrlRead($Radio1))
            IniWrite($sConfig, "Config", "Radio2", GUICtrlRead($Radio2))
            Exit
    EndSwitch
WEnd

 

Thanks :). Is that the only way to save State of Radio and Checkbox ?

Share this post


Link to post
Share on other sites
Subz

No,

Share this post


Link to post
Share on other sites
antonioj84

you can create a property file as well to do that

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

×