Bei Klick auf Button in einer Gui + 1 Addieren und Anzeigen

  • Hi,
    ist es möglich, das wenn ich auf einen Button in einer GUI klicke, + 1 dazu gerechnet wird und es dann auch angezeigt wird?

    Also quasi wenn jedesmal der Button angeklickt wird, rechnet sich das Label eins höher.

    Habe es so versucht:

    [autoit]


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

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

    #Region ### START Koda GUI section ### Form=
    $zahl = "0"
    $Form1 = GUICreate("Form1", 221, 334, 193, 125)
    $Group1 = GUICtrlCreateGroup("Group1", 32, 16, 161, 81)
    $Label1 = GUICtrlCreateLabel($zahl, 48, 32, 36, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("add", 16, 128, 177, 41, 0)
    GUICtrlSetOnEvent($Button1,"_add1")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func _add1()
    $zahl = $zahl + 1
    EndFunc

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Jemand ne Ahnung?

    Einmal editiert, zuletzt von Desaster (5. Februar 2009 um 00:51)

  • Ich habe mal alle zeilen markiert die ich geändert habe + die sachen aus der whileschleife gelöscht

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GUIOnEventMode", 1);<<<<<<<<<<<<<<<<<<<<<<<<<<<<

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

    #Region ### START Koda GUI section ### Form=
    $zahl = "0"
    $Form1 = GUICreate("Form1", 221, 334, 193, 125)
    $Group1 = GUICtrlCreateGroup("Group1", 32, 16, 161, 81)
    $Label1 = GUICtrlCreateLabel($zahl, 48, 32, 36, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("add", 16, 128, 177, 41, 0)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUICtrlSetOnEvent($Button1,"_add1")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func _add1()
    $zahl = GUICtrlRead($Label1);<<<<<<<<<<<<<<<<<<<<<<<<<
    $zahl = $zahl + 1
    GUICtrlSetData($Label1, $zahl);<<<<<<<<<<<<<<<<<<<<<<
    EndFunc

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

    Func _exit() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Exit
    EndFunc

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

    While 1

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

    WEnd

    [/autoit]

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D