Jump to content

Can a GUI have 2 sets of radio buttons ?


Recommended Posts

straight from 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

i did not write this... you need to look at the bottom of each page in the help file

just use the search "tab" and search a word like "radio"

thats all i did ... just now

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I always assign a handle to a control and that way I know which control has received user input, independently of whether the controls are of the same type. The question is analogous to how you handle a gui with two buttons.

IVAN

Edited by ivan
Link to comment
Share on other sites

Thanks but i dont understand how that script is answering my question. I can't see in that script how it's related radio button in any way. Btw i wish my auoit help can have the search function too, it wont let me search.

Here is an example

#include <GUIConstants.au3>

GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

GUICtrlCreateGroup ("Group 1", 190, 60, 90, 140)
$radio_1 = GUICtrlCreateRadio ("Radio 1", 210, 90, 60, 20)
$radio_2 = GUICtrlCreateRadio ("Radio 2", 210, 110, 60, 50)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUICtrlCreateGroup ("Group 2", 190, 200, 90, 140)
$radio_3 = GUICtrlCreateRadio ("Radio 3", 210, 230, 60, 20)
$radio_4 = GUICtrlCreateRadio ("Radio 4", 210, 250, 60, 50)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState ()    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Perhaps you should reload AutoIt if the help does not work properly


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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