Sign in to follow this  
Followers 0
Swimming_Bird

Radio Button Useage

3 posts in this topic

#1 ·  Posted (edited)

I was wondering how you tie radio buttons together so that you can designate that of this set of buttons only one can be checked while leaving another set of buttons of which only 1 of them can be checked.

I saw no such grouping in the example from the help file

#include <GUIConstants.au3>
GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
Edited by Swimming_BIrd

Share this post


Link to post
Share on other sites



*** straight from beta help

#include <GUIconstants.au3>

Opt("GUICoordMode", 1)

GUICreate("Radio Box Grouping Demo", 400,280)

; Create the controls

$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)

$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)

GUIStartGroup()

$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)

$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)

$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)

GUIStartGroup()

$radio_4 = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)

$radio_5 = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)

$radio_6 = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)

GUIStartGroup()

$input_1 = GUICtrlCreateInput ("Input 1", 200, 20, 160, 30)

$input_2 = GUICtrlCreateInput ("Input 2", 200, 70, 160, 30)

; Set the defaults (radio buttons clicked, default button, etc)

GUICtrlSetState($radio_1, $GUI_CHECKED)

GUICtrlSetState($radio_6, $GUI_CHECKED)

GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)

; Init our vars that we will use to keep track of radio events

$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button

$radioval2 = 2

GUISetState ()

; In this message loop we use variables to keep track of changes to the radios, another

; way would be to use GUICtrlRead() at the end to read in the state of each control. Both

; methods are equally valid

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $button_1

MsgBox(0, "Button", "Radio " & $radioval1 & @LF & "Radio " & Chr($radioval2 + Asc("A")) & @LF & GUICtrlRead($input_1) & @LF & GUICtrlRead($input_2))

Case $msg = $radio_1 OR $msg = $radio_2 OR $msg = $radio_3

$radioval1 = $msg - $radio_1

Case $msg = $radio_4 OR $msg = $radio_5 OR $msg = $radio_6

$radioval2 = $msg - $radio_4

EndSelect

WEnd


NEWHeader1.png

Share this post


Link to post
Share on other sites

i'm just running the latest stable version.

and thanks.

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
Sign in to follow this  
Followers 0