Jump to content

Recommended Posts

  • Moderators
Posted

nlta1992,

Something like this perhaps?

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Array to hold button ControlIDs
Global $aButton[11]

$hGUI = GUICreate("Test", 500, 500)

; A double loop to space out the buttons - but you could very easily have a single one instead
For $i = 0 To 1
    For $j = 1 To 5
        $iIndex = ($i * 5) + $j
        ; Create button using a suitable algorithm to locate it
        $aButton[$iIndex] = GUICtrlCreateButton("Button " & $iIndex, 10 + (250 * $i), ($j * 50) - 30, 80, 30)
    Next
Next

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ; See if a button was pressed
            For $i = 1 To 10
                If $iMsg = $aButton[$i] Then
                    ; Do what is necessary
                    MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i)
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

antonioj84,

Simply replace GUICtrlCreateButton with GUICtrlCreateRadio.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

adding unique name radio button

; Array to hold button ControlIDs
;Global $aButton[11]    ; 4x 5 = 21
Global $aButton[11]
Global $aName[11]=["0","Ajohn","Bjohn","Cjohn","Djohn","Ejohn","Fjohn","Jjohn","Hjohn","Ijohn","Jjohn"]
$hGUI = GUICreate("Test", 500, 500)

; A double loop to space out the buttons - but you could very easily have a single one instead
For $i = 0 To 1        ; 0 to 3  x4
    For $j = 1 To 5
        $iIndex = ($i * 5) + $j
        ; Create button using a suitable algorithm to locate it
        $aButton[$iIndex] = GUICtrlCreateRadio($aName[$iIndex] &$iIndex, 10 + (150 * $i), ($j * 50) - 30, 80, 30) ; $index,20
    Next
Next

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ; See if a button was pressed
            For $i = 1 To 10             ;20
                If $iMsg = $aButton[$i] Then
                    ; Do what is necessary
                    MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i)
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd

 

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
×
×
  • Create New...