Jump to content

Some help with radiobuttons and read and write


Raffav
 Share

Recommended Posts

Hello,

What would be the best way to get previously selected radiobutton.

I'm making a GUI that has some radio buttons, when I select one and press a button "Save" it will save the radio button I choose, so that in future reference (re run the GUI) when pressing a button "Read" i will get the the radio button selected before

it will read and write using the Reg Widnows however for testing purposes I'm using variables for now.

i was using "GUICtrlSetState("controID", $GUI_CHECKED)"

but i don't know if the controlid is always the same

Sorry for bad English if someone doesn't understand i will try to explain again better

i can later post the code, but English is not my native language so the variables and msg is not in English.

Thanks

Link to comment
Share on other sites

  • Moderators

Raffav,

Something like this should do the trick: ;)

#include <GUIConstantsEx.au3>

; Decalre an array to hold the ControlIDs
Global $aRadio[5]

; Read the ini to get the set button
$iRadioIndex = IniRead("Radio.ini", "Radio", "Set", -1)

$hGUI = GUICreate("Test", 500, 500)

GUIStartGroup()

; Create the radios and set the one saved in the ini
For $i = 0 To 4
    $aRadio[$i] = GUICtrlCreateRadio(" Radio " & $i + 1, 10, 10 + (20 * $i), 200, 20)
    If $i = $iRadioIndex Then
        GUICtrlSetState(-1, $GUI_CHECKED)
    EndIf
Next

GUIStartGroup()

$cButton = GUICtrlCreateButton("Save Radio", 10, 150, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            ; Check through the radios to find the one checked
            For $i = 0 To 4
                If GUICtrlRead($aRadio[$i]) = 1 Then
                    ; Save that value in the ini
                    IniWrite("Radio.ini", "Radio", "Set", $i)
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd

All clear? :)

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

 

Link to comment
Share on other sites

Thanks, for your help, i would need to do some modification but i think that can use it.

i cant test it right now but in this way is the for next loop that is creating the RadioButtuns, but it will work in this way : when the Radios is already created ?

"

$Radio1 = GUICtrlCreateRadio("low", 24, 281, 49, 17) ;low

$Radio2 = GUICtrlCreateRadio("Normal", 80, 281, 57, 17); normal

$Radio3 = GUICtrlCreateRadio("high", 144, 281, 49, 17);high

"

Edited by Raffav
Link to comment
Share on other sites

  • Moderators

Raffav,

You can do that yourself - just edit the first post and select the "Use Full Editor" option to open up the title for editing. ;)

But if you are going to ask a more complicated question regarding those control types, I suggest you start another thread. :)

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

 

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...