Problem mit GUICtrlCreateGraphic

  • Guten Abend,

    ich habe bei folgenden Code folgendes Problem:

    [autoit]

    #include <GuiConstantsEx.au3>

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

    $Gui = GUICreate("My GUI", 1000, 500)
    $Button = GUICtrlCreateButton("test", 20, 20, 50)
    $Graphic = GUICtrlCreateGraphic(20, 50, 500, 200)
    GUICtrlSetBkColor($Graphic, 0xffffff)
    GUICtrlSetColor($Graphic, 0x000000)
    GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0x000000, 0xffffff)
    GUICtrlSetGraphic($Graphic, $GUI_GR_ELLIPSE, 100, 100, 10, 10)
    GUISetState (@SW_SHOW)

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

    While 1
    $msg = GUIGetMsg()

    Sleep(50)

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

    [/autoit]

    Problem:
    Ich möchte wenn ich den Button drücke, dass sich der Kreis rot färbt und wenn ich wieder loslasse zurück zu weiß. Ich hab die ganze Zeit schon hin und her probiert, aber es nicht geschafft. Kann mir jemand helfen?

  • EDIT: jetzt siehts sogar geclickt aus! Ich bin echt stolz auf meine arbeit xD // achso und die farben stimmen alle nicht..ich hab einfach alles umgekehrt gemacht, aber das wirste schon schaffen anzupassen..

    Spoiler anzeigen
    [autoit]


    #include <GuiConstantsEx.au3>
    #include "misc.au3"

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

    $Gui = GUICreate("My GUI", 1000, 500)
    $my = GUICtrlCreateLabel ("",20, 20, 50, 25)
    $Button = GUICtrlCreateButton("test", 20, 20, 50, 25)
    $Graphic = GUICtrlCreateGraphic(20, 50, 500, 200)
    GUICtrlSetBkColor($Graphic, 0xffffff)
    GUICtrlSetColor($Graphic, 0x000000)
    GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0x000000, 0xffffff)
    GUICtrlSetGraphic($Graphic, $GUI_GR_ELLIPSE, 100, 100, 10, 10)
    GUISetState (@SW_SHOW)
    warten()

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

    Func warten()
    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $my
    farb()
    Case $button
    MsgBox (0,0,"Button gedrückt!")
    EndSwitch
    Wend
    EndFunc

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

    Func farb()
    GUICtrlSetState ($button, $GUI_DISABLE)
    GUICtrlSetBkColor($Graphic, 0x000000)
    GUICtrlSetColor($Graphic, 0xffffff)
    While 1
    If NOT _IsPressed ("01") Then
    stand()
    EndIf
    WEnd
    EndFunc

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

    Func stand()
    GUICtrlSetState ($button, $GUI_ENABLE)
    GUICtrlSetBkColor($Graphic, 0xffffff)
    GUICtrlSetColor($Graphic, 0x000000)
    MsgBox (0,0,"Button gedrückt!")
    warten()
    EndFunc

    [/autoit]

    5 Mal editiert, zuletzt von unaimed (11. März 2009 um 23:40)