Gui mit Radio Button

  • Hallo Zusammen,

    ich brauche eure Hilfe.

    Ich will eine Gui erstellen in der man aus verschieden Radio Buttone eine Auswahl treffen kann und dies Auswahl dann im Edit Fenster, als so eine Art Vorschau sieht.

    Habt ihr auf die schnelle ne Möglichkeit??????


    Spoiler anzeigen


    #include <ButtonConstants.au3>

    #include <EditConstants.au3>

    #include <GUIConstantsEx.au3>

    #include <StaticConstants.au3>

    #include <WindowsConstants.au3>

    #Region ### START Koda GUI section ### Form=

    $Form1 = GUICreate("Form1", 556, 336, 192, 121)

    $Group1 = GUICtrlCreateGroup("Group1", 0, 0, 281, 145)

    $Radio2 = GUICtrlCreateRadio("Fliesen", 0, 24, 193, 17)

    $Radio1 = GUICtrlCreateRadio("Holz", 0, 48, 113, 17)

    GUICtrlCreateGroup("", -99, -99, 1, 1)

    $Edit1 = GUICtrlCreateEdit("", 0, 144, 553, 161)

    GUICtrlSetData(-1, "Edit1")

    $Group2 = GUICtrlCreateGroup("Group2", 280, 0, 273, 145)

    $Radio3 = GUICtrlCreateRadio("Bestellt", 280, 24, 113, 17)

    $Radio4 = GUICtrlCreateRadio("Geliefert", 280, 48, 113, 17)

    GUICtrlCreateGroup("", -99, -99, 1, 1)

    $Button2 = GUICtrlCreateButton("
    Übernehmen", 232, 304, 75, 25, $WS_GROUP) 
    GUISetState(@SW_SHOW)

    #EndRegion ### END Koda GUI section ###

    While 1

    $nMsg = GUIGetMsg()

    Switch $nMsg

    Case $GUI_EVENT_CLOSE

    Exit

    Case $Radio2

    EndSwitch

    WEnd

  • Damit kannst du die Texte der Radio Buttons in das Editfeld eintragen:
    Beispielsweise:


    [autoit]

    GUICtrlSetData($Edit1, GUICtrlRead ($Radio3, 1))

    [/autoit]

    greetz Blade

    Weil Denken die schwerste Arbeit ist, die es gibt, beschäftigen sich auch nur wenige damit.

  • Danke, der Befehl klappt.

    Aber wie muss ich jetzt die If Entscheidung formulieren, wenn die unterschiedlich Button angeklickt sind. Oder bin ich mit If völlig falsch?

  • Hallo, mal ein Beispiel....

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Dim $Material_Radio[10] ;platz für 10 Buttons
    Dim $status_Radio[10] ;platz für 10 Buttons

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

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 556, 336, 192, 121)
    $Group1 = GUICtrlCreateGroup("Material", 0, 0, 281, 145)
    $Material_Radio[0] = GUICtrlCreateRadio("Fliesen", 0, 25, 100, 17)
    $Material_Radio[1] = GUICtrlCreateRadio("Holz", 0, 50, 100, 17)
    $Material_Radio[2] = GUICtrlCreateRadio("Sand", 0, 75, 100, 17)
    $Material_Radio[3] = GUICtrlCreateRadio("Eimer", 0, 100, 100, 17)
    $Material_Radio[4] = GUICtrlCreateRadio("Streckmetall", 100, 25, 100, 17)

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

    $Group2 = GUICtrlCreateGroup("Auftrag Status", 280, 0, 273, 145)
    $status_Radio[0] = GUICtrlCreateRadio("Bestellt", 280, 24, 113, 17)
    $status_Radio[1] = GUICtrlCreateRadio("Geliefert", 280, 48, 113, 17)

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

    $Edit1 = GUICtrlCreateEdit("", 0, 144, 553, 161)

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

    $Button2 = GUICtrlCreateButton("Übernehmen", 232, 304, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

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

    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2 ;"Übernehmen" Button abfragen
    _Edit_beschreiben()
    EndSwitch
    WEnd

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

    Func _Edit_beschreiben()
    $material = "" ;noch kein Material ausgewählt
    $Status = "" ;noch kein status ausgewählt
    For $i = 0 To UBound($Material_Radio) - 1 ;alle materialen durchsuchen
    If BitAND(GUICtrlRead($Material_Radio[$i]), $GUI_CHECKED) = $GUI_CHECKED Then ;wenn Material-Radiobutton gechecked, dann
    $material = GUICtrlRead($Material_Radio[$i], 1) ;material merken
    EndIf
    If BitAND(GUICtrlRead($status_Radio[$i]), $GUI_CHECKED) = $GUI_CHECKED Then ;wenn Status-Radiobutton gechecked, dann
    $Status = GUICtrlRead($status_Radio[$i], 1) ;Status merken
    EndIf
    Next
    If $material = "" Then ;kein Material ausgewählt
    MsgBox(0, "Fehler Eingabe", "Es wurde kein Material ausgewählt!")
    Return
    EndIf
    If $Status = "" Then ;kein Status ausgewählt
    MsgBox(0, "Fehler Eingabe", "Es wurde kein Auftrag Status ausgewählt!")
    Return
    EndIf
    $neue_zeile = "Material: " & $material & @TAB & @TAB & "Status: " & $Status ;zeile generieren
    $text = GUICtrlRead($Edit1, 0) ;inhalt EDIT1
    If StringInStr($text, $neue_zeile) = 0 Then ;nur eintragen, falls noch nicht im Edit1 vorhanden
    GUICtrlSetData($Edit1, $text & $neue_zeile & @CRLF)
    EndIf
    EndFunc ;==>_Edit_beschreiben

    [/autoit]