Raffav Posted September 27, 2012 Posted September 27, 2012 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
Moderators Melba23 Posted September 27, 2012 Moderators Posted September 27, 2012 Raffav, Something like this should do the trick: expandcollapse popup#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 Raffav 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Raffav Posted September 27, 2012 Author Posted September 27, 2012 (edited) 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 September 27, 2012 by Raffav
Raffav Posted October 1, 2012 Author Posted October 1, 2012 Please MOD our Adminchange the Title if possible for Some help with radiobuttons, Inputbox,checkbox, read and writethanks
Moderators Melba23 Posted October 1, 2012 Moderators Posted October 1, 2012 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 Raffav 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Raffav Posted October 1, 2012 Author Posted October 1, 2012 Ok, i think i will create another thread so Thanks for your help!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now