Jump to content

Radiobutton Help


spudw2k
 Share

Recommended Posts

Is there a way to make a radiobuttons not affect each other? I want a form that has multiple radio buttons that do not alter each other's selection. So radiobuttons that act like checkboxes, that make sense?

Link to comment
Share on other sites

Maybe something like this:

#include <GuiConstants.au3>

$hWnd = GuiCreate("")

Dim $radio[6]

$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio[0] = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
GUIStartGroup()
$radio[1] = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
GUIStartGroup()
$radio[2] = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)
GUIStartGroup()
$radio[3] = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)
GUIStartGroup()
$radio[4] = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)
GUIStartGroup()
$radio[5] = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)
GUIStartGroup()


GuiSetState()

While 1
    
    $msg = GuiGetMsg()
    
    Switch $msg
        Case -3
            ExitLoop
        Case $radio[0], $radio[1], $radio[2], $radio[3], $radio[4], $radio[5]
            For $x = 0 to 5
                If $msg = $radio[$x] Then 
                Else
                    GUICtrlSetState($radio[$x],$GUI_UNCHECKED)
                EndIf
            Next
    EndSwitch
WEnd
Link to comment
Share on other sites

Oh geez. Sorry, total brainfart there. That does exactly what the default behaviour does. lol. Try this:

#include <GuiConstants.au3>

$hWnd = GuiCreate("")

Dim $radio[6]
Dim $bState[6]

For $x = 0 to 5
    $bState[$x] = False
Next

$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio[0] = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
GUIStartGroup()
$radio[1] = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
GUIStartGroup()
$radio[2] = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)
GUIStartGroup()
$radio[3] = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)
GUIStartGroup()
$radio[4] = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)
GUIStartGroup()
$radio[5] = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)
GUIStartGroup()


GuiSetState()

While 1
   
    $msg = GuiGetMsg()
   
    Switch $msg
        Case -3
            ExitLoop
        Case $radio[0], $radio[1], $radio[2], $radio[3], $radio[4], $radio[5]
            For $x = 0 to 5
                If $msg = $radio[$x] Then
                    $bState[$x] = Not $bState[$x]
                    If $bState[$x] = False Then
                        GUICtrlSetState($radio[$x],$GUI_UNCHECKED)
                    EndIf
                EndIf
            Next
    EndSwitch
WEnd
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...