GUI mit Multiple Choice Auswahl

  • Wie misterspeed gesagt hat, werden dafür eigentlich andere Controls verwendet.
    Aber man kann es mit ein wenig Logik auch so hinbekommen:

    [autoit]

    #include <GUIConstantsEx.au3>

    [/autoit][autoit][/autoit][autoit]

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

    [/autoit][autoit][/autoit][autoit]

    GUICtrlCreateLabel("1", 100, 15, 100, 20)
    GUICtrlCreateLabel("2", 100, 55, 100, 20)
    GUICtrlCreateLabel("3", 100, 95, 100, 20)

    [/autoit][autoit][/autoit][autoit]

    $hButton_1 = GUICtrlCreateButton("False", 10, 10, 80, 30)
    $hButton_2 = GUICtrlCreateButton("False", 10, 50, 80, 30)
    $hButton_3 = GUICtrlCreateButton("False", 10, 90, 80, 30)
    $hButton_S = GUICtrlCreateButton("Show", 10, 130, 80, 30)

    [/autoit][autoit][/autoit][autoit]

    $iFlag = 0

    [/autoit][autoit][/autoit][autoit]

    GUISetState()

    [/autoit][autoit][/autoit][autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hButton_1
    $iFlag = (BitAND($iFlag, 1) ? BitXOR($iFlag, 1) : BitOR($iFlag, 1))
    GUICtrlSetData($hButton_1, (BitAND($iFlag, 1) ? "True" : "False"))
    Case $hButton_2
    $iFlag = (BitAND($iFlag, 2) ? BitXOR($iFlag, 2) : BitOR($iFlag, 2))
    GUICtrlSetData($hButton_2, (BitAND($iFlag, 2) ? "True" : "False"))
    Case $hButton_3
    $iFlag = (BitAND($iFlag, 4) ? BitXOR($iFlag, 4) : BitOR($iFlag, 4))
    GUICtrlSetData($hButton_3, (BitAND($iFlag, 4) ? "True" : "False"))
    Case $hButton_S
    $sOut = "Folgende Buttons sind gesetzt:"
    If BitAND($iFlag, 1) Then $sOut &= " -1-"
    If BitAND($iFlag, 2) Then $sOut &= " -2-"
    If BitAND($iFlag, 4) Then $sOut &= " -3-"
    MsgBox(0, '', $sOut)
    EndSwitch
    WEnd

    [/autoit]
  • Hi,
    ein Button zur Auswahl ist relativ ungünstig. Besser ist definitiv ein Radio-Control

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Radio1 = GUICtrlCreateRadio("Radio1", 16, 32, 100, 33)
    $Radio2 = GUICtrlCreateRadio("Radio2", 16, 80, 100, 41)
    $Radio3 = GUICtrlCreateRadio("Radio3", 16, 136, 100, 41)

    [/autoit] [autoit][/autoit] [autoit]

    $Group1 = GUICtrlCreateGroup("Group1", 8, 8, 250, 217)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    [/autoit] [autoit][/autoit] [autoit]

    $Radio4 = GUICtrlCreateRadio("Radio4", 280, 32, 100, 33)
    $Radio5 = GUICtrlCreateRadio("Radio5", 280, 80, 100, 41)
    $Radio6 = GUICtrlCreateRadio("Radio6", 280, 136, 100, 33)
    $Group2 = GUICtrlCreateGroup("Group2", 264, 8, 250, 217)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("Button1", 264, 320, 153, 65)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    $Antworten = ""
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Case $Button1
    For $i = 1 To 6
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : GUICtrlRead(Eval("radio" & $i)) = ' & GUICtrlRead(Eval("radio" & $i)) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit]

    If BitAND(GUICtrlRead(Eval("radio" & $i)), $GUI_CHECKED) = $GUI_CHECKED Then
    $Antworten &= "Geklickt Radio " & $i & @CRLF
    endif
    Next
    MsgBox(0, "Radio geklickt", $Antworten)
    $Antworten = ""
    exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]