Sign in to follow this  
Followers 0
Fossil Rock

Dynamic radio button controls.

3 posts in this topic

I thought this was clever so I added it here.

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)

$title = "Option "
$Choices = 5
$Counter = 0
Dim $Radio[31]
$GUI = GUICreate("  Radio Button Selector", 170, ($Choices * 20) + 65, -1, -1, "", $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Done")
GUICtrlCreateLabel("Make a Selection", 10, 10)
MakeChoices()
GUISetState(@SW_SHOW)
List1()

Func List1()
While 1
    $msg = GUIGetMsg()
   Select
        Case $msg = $GUI_EVENT_CLOSE
            Done()
    EndSelect
Wend
EndFunc

Func MakeChoices()
For $Counter = 1 To $Choices
    $Radio[$Counter] = GUICtrlCreateRadio($title & $Counter & "  ", 10, ($Counter * 20) + 10)
    GUICtrlSetOnEvent(-1, "SetTitle")
Next
EndFunc

Func SetTitle()
    WinSetTitle("  ", "", "  " & ControlGetText("","",@GUI_CtrlId) & "Selected")
EndFunc

Func Done()
MsgBox(0,"", "Change the $Choices value and see what happens.")
Exit
EndFunc

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

nice script :whistle:

but if you selected radio 3 for example, how do you make to do something?

LE:

Like

Func MakeChoices()

For $Counter = 1 To $Choices

$Radio[$Counter] = GUICtrlCreateRadio($title & $Counter & " ", 10, ($Counter * 20) + 10)

GUICtrlSetOnEvent(-1, "runs")

Next

EndFunc

Func runs()

if $Radio[$Counter] = GUICtrlCreateRadio("key2", 10, 50) Then <----what you must put here (instead "key2", 10, 50 )

MsgBox (0, "1", "OK. Match")

Else

MsgBox (0, "2", "Not a match")

EndIf

EndFunc

where Key is title and 2 is the option

Edited by erikson

Share this post


Link to post
Share on other sites

Look at the Function Call in the help file. Hope this helps.

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)

$title = "Option "
$Choices = 5
$Counter = 0
Dim $Radio[31]
$GUI = GUICreate("  Radio Button Selector", 170, ($Choices * 20) + 65, -1, -1, "", $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Done")
GUICtrlCreateLabel("Make a Selection", 10, 10)
MakeChoices()
GUISetState(@SW_SHOW)
List1()

Func List1()
While 1
    $msg = GUIGetMsg()
   Select
        Case $msg = $GUI_EVENT_CLOSE
            Done()
    EndSelect
Wend
EndFunc

Func MakeChoices()
For $Counter = 1 To $Choices
    $Radio[$Counter] = GUICtrlCreateRadio($title & $Counter & "  ", 10, ($Counter * 20) + 10)
    GUICtrlSetOnEvent(-1, "SetTitle")
Next
EndFunc

Func SetTitle()
    WinSetTitle("  ", "", "  " & ControlGetText("","",@GUI_CtrlId) & "Selected")
    $Box = "Option" & @GUI_CtrlId - 3
    Call($Box)
EndFunc

Func Done()
; MsgBox(0,"", "Change the $Choices value and see what happens.")
Exit
EndFunc

Func Option1()
    MsgBox (0,"", "Option " & @GUI_CtrlId - 3 & " Selected")
EndFunc

Func Option2()
    MsgBox (0,"", "Option " & @GUI_CtrlId - 3 & " Selected")
EndFunc

Func Option3()
    MsgBox (0,"", "Option " & @GUI_CtrlId - 3 & " Selected")
EndFunc

Func Option4()
    MsgBox (0,"", "Option " & @GUI_CtrlId - 3 & " Selected")
EndFunc

Func Option5()
    MsgBox (0,"", "Option " & @GUI_CtrlId - 3 & " Selected")
EndFunc

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

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