user32.dll AnimateWindow funktioniert nur einmal

  • Jemand eine Idee, warum nach erfolgreicher Ausführung der Fensteranimation (Button1) keine weiteren Animationen mehr möglich sind? Scheinbar können danach keinerlei Buttons mehr genutzt werden, das eingebaute Timerlabel zeigt aber, dass das Programm ansich noch innerhalb der GUI Schleife ist und somit auch GUI messages auswerten sollte. Lässt man sich alle GUI messages (ungleich 0) in die console ausgeben sieht man auch die messages für Mausklicks, allerdings keine Messages bei Klicks auf Controls. Ich bin ein wenig verwirrt.


    Spoiler anzeigen
    [autoit]


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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 615, 438, 192, 124)
    GUISetBkColor(0x0066CC)
    $Button1 = GUICtrlCreateButton("Button1", 64, 64, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 112, 184, 75, 25)
    $Button3 = GUICtrlCreateButton("Button3", 360, 208, 75, 25)
    $aliveLabel = GUICtrlCreateLabel("",300,50,100,20)
    $Edit1 = GUICtrlCreateEdit("", 88, 288, 473, 121)
    GUICtrlSetData(-1, "Edit1")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    $test = TimerInit()
    $i = 0
    While 1
    $nMsg = GUIGetMsg()
    if $nMsg > 0 Then ConsoleWrite("nMsg id: " & $nMsg & @CRLF)
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    ConsoleWrite("button1 function called" & @CRLF)
    GUISetState(@SW_HIDE,$Form1)
    $hwnd = WinGetHandle($Form1)
    $result = DllCall("user32.dll", "BOOL", "AnimateWindow", "hwnd", $hwnd, "dword", 5000, "dword", 131072+5) ; activate + diagonal
    If @error <> 0 Then
    ConsoleWrite("ERROR: " & @error & @CRLF)
    GUISetState(@SW_SHOW,$Form1)
    Else
    if IsArray($result) Then
    ;_ArrayDisplay($result)
    Else
    ConsoleWrite("String 1: " & $result & @CRLF)
    EndIf
    EndIf
    Case $Button2
    ConsoleWrite("button2 function called" & @CRLF)
    $temp = GUISetState(@SW_HIDE,$Form1)
    ConsoleWrite("return hide: " & $temp & @CRLF)
    Sleep(3000)
    $temp = GUISetState(@SW_SHOW,$Form1)
    ConsoleWrite("return show: " & $temp & @CRLF)
    EndSwitch
    If TimerDiff($test) > 1000 Then
    $i+=1
    GUICtrlSetData($aliveLabel,$i)
    $test = TimerInit()
    EndIf
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von misterspeed (25. Mai 2013 um 18:33)

    • Offizieller Beitrag

    Hallo,

    Du musst nach der Animation noch ein SW_SHOW senden:

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 615, 438, 192, 124)
    GUISetBkColor(0x0066CC)
    $Button1 = GUICtrlCreateButton("Button1", 64, 64, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 112, 184, 75, 25)
    $Button3 = GUICtrlCreateButton("Button3", 360, 208, 75, 25)
    $aliveLabel = GUICtrlCreateLabel("",300,50,100,20)
    $Edit1 = GUICtrlCreateEdit("", 88, 288, 473, 121)
    GUICtrlSetData(-1, "Edit1")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    $test = TimerInit()
    $i = 0
    While 1
    $nMsg = GUIGetMsg()
    if $nMsg > 0 Then ConsoleWrite("nMsg id: " & $nMsg & @CRLF)
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    ConsoleWrite("button1 function called" & @CRLF)
    GUISetState(@SW_HIDE,$Form1)
    $hwnd = WinGetHandle($Form1)
    $result = DllCall("user32.dll", "BOOL", "AnimateWindow", "hwnd", $hwnd, "dword", 5000, "dword", 131072+5) ; activate + diagonal
    If @error <> 0 Then
    ConsoleWrite("ERROR: " & @error & @CRLF)
    Else
    if IsArray($result) Then
    ;_ArrayDisplay($result)
    Else
    ConsoleWrite("String 1: " & $result & @CRLF)
    EndIf
    EndIf
    GUISetState(@SW_SHOW,$Form1)
    Case $Button2
    ConsoleWrite("button2 function called" & @CRLF)
    $temp = GUISetState(@SW_HIDE,$Form1)
    ConsoleWrite("return hide: " & $temp & @CRLF)
    Sleep(3000)
    $temp = GUISetState(@SW_SHOW,$Form1)
    ConsoleWrite("return show: " & $temp & @CRLF)
    EndSwitch
    If TimerDiff($test) > 1000 Then
    $i+=1
    GUICtrlSetData($aliveLabel,$i)
    $test = TimerInit()
    EndIf
    WEnd

    [/autoit]

    Gruß
    Spider

  • Danke, das wars. Bin eigentlich davon ausgegangen, dass das automatisch gesetzt wird (zumal das Fenster ja zu sehen ist), aber so kann man sich täuschen.

    Hier noch der MSDN Link, falls es jemand nutzen will: http://msdn.microsoft.com/en-us/library/…v=vs.85%29.aspx

    Bei aktiviertem Aero Design macht das ganze aber nur Sinn, wenn man den Popup Fensterstil nutzt, da der Fensterrahmen bei aktiviertem Aero scheinbar nicht mit animiert wird.