Gui will keine Icons mehr erstellen :(

  • Ich habe vor, ein kleines Game zu machen. Leider erstellt das Script beim Nachladen der Muition die Icons nicht mehr.

    Hoffe es kann mir jemand helfen :=)

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <ButtonConstants.au3>
    #include<misc.au3>
    Global $max_ammo = 5, $current_ammo=5,$timerinit=50, $timerinit2=50,$nullammo="0",$null1=0,$null2=0,$null3=0,$null4=0,$null5=0
    lvl_1()

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

    Func lvl_1(); ==> lvl_1
    $level="1"
    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Sebastian\Desktop\autoit\spiel\lvl_1.kxf
    $lvl_1 = GUICreate("Level_1", 838, 602, 200, 137, $WS_POPUP)
    $Pic1 = GUICtrlCreatePic("background.jpg", 0, 0, 836, 508, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetCursor(-1, 3)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic2 = GUICtrlCreatePic("menu.jpg", 0, 508, 836, 92, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $btn = GUICtrlCreateIcon("exit.ico", -1, 745, 508, 92, 92) ; --> die letzte 0, damit kein Klick-Ereignis ausgelöst wird (Click-Through)
    $Label1 = GUICtrlCreateLabel("Munition:", 16, 512, 90, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1,0x5e2d64)
    $Label2 = GUICtrlCreateLabel("Leben:", 16, 536, 69, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1,0x5e2d64)
    $Label3 = GUICtrlCreateLabel("Level: " & $level, 16, 568, 200, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1,0x5e2d64)
    global $leben1 = GUICtrlCreateIcon("leben.ico", -1, 144, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $leben2 = GUICtrlCreateIcon("leben.ico", -1, 112, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $leben3 = GUICtrlCreateIcon("leben.ico", -1, 176, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $leben4 = GUICtrlCreateIcon("leben.ico", -1, 208, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $leben5 = GUICtrlCreateIcon("leben.ico", -1, 240, 544, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###
    _GuiRoundCorners($lvl_1, 0, 0, 50, 50)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btn
    main_gui()

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

    EndSwitch
    check_ammo()
    WEnd
    EndFunc ;==>lvl_1

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

    func main_gui() ;==> Hauptfenster
    exit(1)
    endfunc ;==> Hauptfenster

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

    func check_ammo()
    if _IsPressed('01') Then
    $timerdiff= TimerDiff($timerinit)
    if $timerdiff >= 100 Then
    if $current_ammo = 5 then
    GUICtrlDelete($ammo5)
    $null5=1
    endif
    if $current_ammo = 4 then
    GUICtrlDelete($ammo4)
    $nullammo4=1
    endif
    if $current_ammo = 3 then
    GUICtrlDelete($ammo3)
    $nullammo3=1
    endif
    if $current_ammo = 2 then
    GUICtrlDelete($ammo2)
    $nullammo2=1
    endif
    if $current_ammo = 1 then
    GUICtrlDelete($ammo1)
    $nullammo1=1
    endif
    if $current_ammo = 0 Then
    global $nullammo="1"
    global $Label4 = GUICtrlCreateLabel("!!!!Keine Munition!!!!", 280, 184, 297, 42)
    GUICtrlSetFont(-1, 20, 800, 0, "Arial Black")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1,0xe2b75b)
    ;Hier sieht man dann nur den letze Hülse, die wird aber öffters erstellt, da man nach 5 mal drücken nicht verschwindet.
    ;eigentlich sollen hier wieder alle Hülsen so schön in der Reihe stehen, wie am Anfang. Und jedes nur 1mal.
    global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    endif
    $current_ammo=$current_ammo -1
    endif
    $timerinit=TimerInit()
    endif
    if _IsPressed('02') Then ; Hier brauch ich Hilfe: er erstellt die Icons nicht wieder her, theoretisch geht alles, aber die werden nicht mehr angezeigt.
    $timerdiff2=TimerDiff($timerinit2)
    if $timerdiff2 >= 500 then
    if $nullammo ="1" then
    GUICtrlDelete($label4)
    $nullammo="0"
    endif
    if $null5=1 Then
    global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    $current_ammo=5
    EndIf
    if $null4=1 Then
    global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    $current_ammo=4
    EndIf
    if $null3=1 Then
    global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    $current_ammo=3
    EndIf
    if $null2=1 Then
    global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    $current_ammo=2
    EndIf
    if $null1=1 Then
    global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
    $current_ammo=1
    EndIf
    endif
    $timerinit2 =TimerInit()
    endif
    endfunc

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

    ;#######Zusatzfunktion####################
    Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Dim $pos, $ret, $ret2
    $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
    If $ret[0] Then
    $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
    If $ret2[0] Then
    Return 1
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    EndFunc ;==>_GuiRoundCorners

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

    MFG Sebastian

    Einmal editiert, zuletzt von der Scripter (20. Juni 2009 um 20:46)

  • Hallo der Scripter,

    dein Script lies sich nicht starten, ich habe es daher etwas angepasst damit ich es starten kann und auch die komplette Gui auf mein Display passt,

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <ButtonConstants.au3>
    #include<misc.au3>
    Global $max_ammo = 5, $current_ammo = 5, $timerinit = 50, $timerinit2 = 50, $nullammo = "0", $null1 = 0, $null2 = 0, $null3 = 0, $null4 = 0, $null5 = 0
    Global $ammo1, $ammo2, $ammo3, $ammo4, $ammo5
    lvl_1()

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

    Func lvl_1(); ==> lvl_1
    $level = "1"
    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Sebastian\Desktop\autoit\spiel\lvl_1.kxf
    $lvl_1 = GUICreate("Level_1", 838, 602, 0, 0, $WS_POPUP)
    $Pic1 = GUICtrlCreatePic("background.jpg", 0, 0, 836, 508, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetCursor(-1, 3)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic2 = GUICtrlCreatePic("menu.jpg", 0, 508, 836, 92, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $btn = GUICtrlCreateIcon("exit.ico", -1, 745, 508, 92, 92) ; --> die letzte 0, damit kein Klick-Ereignis ausgelöst wird (Click-Through)
    $Label1 = GUICtrlCreateLabel("Munition:", 16, 512, 90, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x5e2d64)
    $Label2 = GUICtrlCreateLabel("Leben:", 16, 536, 69, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x5e2d64)
    $Label3 = GUICtrlCreateLabel("Level: " & $level, 16, 568, 200, 28)
    GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x5e2d64)
    Global $leben1 = GUICtrlCreateIcon("leben.ico", -1, 144, 544, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $leben2 = GUICtrlCreateIcon("leben.ico", -1, 112, 544, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $leben3 = GUICtrlCreateIcon("leben.ico", -1, 176, 544, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $leben4 = GUICtrlCreateIcon("leben.ico", -1, 208, 544, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $leben5 = GUICtrlCreateIcon("leben.ico", -1, 240, 544, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###
    _GuiRoundCorners($lvl_1, 0, 0, 50, 50)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btn
    ; main_gui()

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

    EndSwitch
    check_ammo()
    WEnd
    EndFunc ;==>lvl_1

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

    Func main_gui() ;==> Hauptfenster
    Exit (1)
    EndFunc ;==>main_gui

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

    Func check_ammo()
    If _IsPressed('01') Then
    $timerdiff = TimerDiff($timerinit)
    If $timerdiff >= 100 Then
    If $current_ammo = 5 Then
    GUICtrlDelete($ammo5)
    $null5 = 1
    EndIf
    If $current_ammo = 4 Then
    GUICtrlDelete($ammo4)
    $nullammo4 = 1
    EndIf
    If $current_ammo = 3 Then
    GUICtrlDelete($ammo3)
    $nullammo3 = 1
    EndIf
    If $current_ammo = 2 Then
    GUICtrlDelete($ammo2)
    $nullammo2 = 1
    EndIf
    If $current_ammo = 1 Then
    GUICtrlDelete($ammo1)
    $nullammo1 = 1
    EndIf
    If $current_ammo = 0 Then
    Global $nullammo = "1"
    Global $Label4 = GUICtrlCreateLabel("!!!!Keine Munition!!!!", 280, 184, 297, 42)
    GUICtrlSetFont(-1, 20, 800, 0, "Arial Black")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0xe2b75b)
    ;Hier sieht man dann nur den letze Hülse, die wird aber öffters erstellt, da man nach 5 mal drücken nicht verschwindet.
    ;eigentlich sollen hier wieder alle Hülsen so schön in der Reihe stehen, wie am Anfang. Und jedes nur 1mal.
    Global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    Global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    EndIf
    $current_ammo = $current_ammo - 1
    EndIf
    $timerinit = TimerInit()
    EndIf
    If _IsPressed('02') Then ; Hier brauch ich Hilfe: er erstellt die Icons nicht wieder her, theoretisch geht alles, aber die werden nicht mehr angezeigt.
    $timerdiff2 = TimerDiff($timerinit2)
    If $timerdiff2 >= 500 Then
    If $nullammo = "1" Then
    GUICtrlDelete($Label4)
    $nullammo = "0"
    EndIf
    If $null5 = 1 Then
    Global $ammo5 = GUICtrlCreateIcon("munition.ico", -1, 240, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    $current_ammo = 5
    EndIf
    If $null4 = 1 Then
    Global $ammo4 = GUICtrlCreateIcon("munition.ico", -1, 208, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    $current_ammo = 4
    EndIf
    If $null3 = 1 Then
    Global $ammo3 = GUICtrlCreateIcon("munition.ico", -1, 176, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    $current_ammo = 3
    EndIf
    If $null2 = 1 Then
    Global $ammo2 = GUICtrlCreateIcon("munition.ico", -1, 144, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    $current_ammo = 2
    EndIf
    If $null1 = 1 Then
    Global $ammo1 = GUICtrlCreateIcon("munition.ico", -1, 112, 512, 25, 25, BitOR($SS_NOTIFY, $WS_GROUP))
    $current_ammo = 1
    EndIf
    EndIf
    $timerinit2 = TimerInit()
    EndIf
    EndFunc ;==>check_ammo

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

    ;#######Zusatzfunktion####################
    Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Dim $pos, $ret, $ret2
    $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
    If $ret[0] Then
    $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
    If $ret2[0] Then
    Return 1
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    EndFunc ;==>_GuiRoundCorners

    [/autoit]

    Jetzt fehlen nur noch die Icons und man kann testen. Ich vertehe aber nicht warum die Icons löscht um sie dann später wieder zu erstellen, nutze doch einfach die Funktion GuiCtrlSetState() mit $GuiHide bzw. $GuiShow

    mfg (Auto)Bert

  • stimmt. das ist eine gute Iddeee :=)

    Diese Funktion hab ich glad vergessen :=)

    vielen dank.


    Stimmt, ich habe vergessen die Icons zu posten :(

    Naja danke vielmals...

    MFG Sebastian