Jump to content

Verify radio button selected


McGyver
 Share

Recommended Posts

I am trying to force a radio button to be selected, but am not sure how to verify that a button is selected, and if one is not how to send a message saying no button selected and then go back to waiting for a button selection. Any help is appreciated.

#include <GUIConstants.au3>

; Setup Menu Window

GuiCreate("Account", 370, 180)

GuiCtrlCreateLabel("Select Region", 10, 10)

GuiSetIcon(" ", 0)

; Create Selection ButtonR1

$Button1r1 = GUICtrlCreateButton("Select", 120, 70, 75, 20)

; Create Radio Buttons

GuiCtrlSetState(-1, $GUI_CHECKED)

$radio1 = GuiCtrlCreateRadio("1 Region", 15, 25, 100)

$radio2 = GuiCtrlCreateRadio("2 Region", 15, 45, 100)

$radio3 = GuiCtrlCreateRadio("3 Region", 15, 65, 100)

$radio4 = GuiCtrlCreateRadio("4 Region", 15, 85, 100)

$radio5 = GuiCtrlCreateRadio("5 Region", 15, 105, 100)

$radio6 = GuiCtrlCreateRadio("6 Region", 15, 125, 100)

$radio7 = GuiCtrlCreateRadio("7 Region", 15, 145, 100)

GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState(@SW_SHOW)

; Process region and set E-mail addresses

func region_select()

local $To = ''

$radio1_state = GUICtrlRead($radio1)

$radio2_state = GUICtrlRead($radio2)

$radio3_state = GUICtrlRead($radio3)

$radio4_state = GUICtrlRead($radio4)

$radio5_state = GUICtrlRead($radio5)

$radio6_state = GUICtrlRead($radio6)

$radio7_state = GUICtrlRead($radio7)

Select

Case $radio1_state = $GUI_CHECKED

$To = '1'

Case $radio2_state = $GUI_CHECKED

$To = '2'

Case $radio3_state = $GUI_CHECKED

$To = '3'

Case $radio4_state = $GUI_CHECKED

$To = '4'

Case $radio5_state = $GUI_CHECKED

$To = '5'

Case $radio6_state = $GUI_CHECKED

$To = '6'

Case $radio7_state = $GUI_CHECKED

$To = '7'

EndSelect

Return $To

EndFunc

Link to comment
Share on other sites

You could check all of them with $GUI_UNCHECKED, or you could set a variable that is initially "0" and _select() changes it to "1". I myself would totally prefer the second way.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

#include <GUIConstants.au3>

; Setup Menu Window
GuiCreate("Account", 370, 180)
GuiCtrlCreateLabel("Select Region", 10, 10)
GuiSetIcon(" ", 0)

; Create Selection ButtonR1
$Button1r1 = GUICtrlCreateButton("Select", 120, 70, 75, 20)

; Create Radio Buttons
GuiCtrlSetState(-1, $GUI_CHECKED)
$radio1 = GuiCtrlCreateRadio("1 Region", 15, 25, 100)
$radio2 = GuiCtrlCreateRadio("2 Region", 15, 45, 100)
$radio3 = GuiCtrlCreateRadio("3 Region", 15, 65, 100)
$radio4 = GuiCtrlCreateRadio("4 Region", 15, 85, 100)
$radio5 = GuiCtrlCreateRadio("5 Region", 15, 105, 100)
$radio6 = GuiCtrlCreateRadio("6 Region", 15, 125, 100)
$radio7 = GuiCtrlCreateRadio("7 Region", 15, 145, 100)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group
GUISetState(@SW_SHOW)

; Process region and set E-mail addresses
func region_select()
    $iRegion = 0
    For $i = $Radio1 To $Radio7
        $iRegion += 1
        If GUICtrlRead($i) = 1 Then Return $iRegion
    Next
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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