Sign in to follow this  
Followers 0
LarsJ

AnimateWindow example: Roll window up to small title bar

2 posts in this topic

Found this example in the AutoHotkey Forum.

The example is too small for the Example Scripts so I have posted it here. I'm not asking for help.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
AutoItSetOption( "MustDeclareVars", 1 )
;Globals
Global $hGUI, $fGuiRolledUp = 0, $iTitleBarWidth = 150, $iTitleBarHeight = 20, $dllUser32 = DllOpen( "user32.dll" )
MainProgram()
Func MainProgram()
$hGUI = GUICreate( "RollGui", 300, 200, 650, 300, -1, $WS_EX_TOPMOST )
GUICtrlCreateLabel( "", 40, 40, 220, 120, $SS_ETCHEDFRAME )
GUICtrlCreateLabel( "Click outside the window to roll window up to small titlebar." & @CRLF & @CRLF & _
           "Move cursor over titlebar to restore window.", 50, 50, 200, 100 )
GUIRegisterMsg( $WM_ACTIVATE, "WM_ACTIVATE" )
GUISetState( @SW_SHOW )
While 1
  Local $msg = GUIGetMsg(1)
  Switch $msg[1]
   Case $hGUI
    Switch $msg[0]
     Case $GUI_EVENT_CLOSE
      ExitLoop
    EndSwitch
  EndSwitch
  If $fGuiRolledUp Then
   Sleep( 200 )
   Local $mPos = MouseGetPos()
   Local $wPos = WinGetPos( $hGUI )
   If $mPos[0] > $wPos[0] And $mPos[0] < $wPos[0] + $iTitleBarWidth _
   And $mPos[1] > $wPos[1] And $mPos[1] < $wPos[1] + $iTitleBarHeight Then
    RollGuiDown( $hGUI )
   EndIF
  EndIf
WEnd
GUIRegisterMsg( $WM_ACTIVATE, "" )
DllClose( $dllUser32 )
GUIDelete( $hGUI )
Exit
EndFunc
Func WM_ACTIVATE( $hWnd, $Msg, $wParam, $lParam )
Switch $hWnd
  Case $hGUI
   If Not $wParam Then
    If Not $fGuiRolledUp Then
     RollGuiUp( $hGUI )
    EndIf
   EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func RollGuiUp( $hWnd )
Global $hRollGuiUp
Local $wPos = WinGetPos( $hWnd )
Local $sBarName = WinGetTitle ( $hWnd )
$hRollGuiUp = GUICreate( $sBarName, $iTitleBarWidth, 0, $wPos[0], $wPos[1], BitXOR( $GUI_SS_DEFAULT_GUI, $WS_SYSMENU ), BitOR( $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST ) )
GUISetState( @SW_SHOW )
  DllCall( $dllUser32, "int", "AnimateWindow", "hwnd", $hGUI, "int", 200, "long", "0x3000A" )
$fGuiRolledUp = 1
EndFunc
Func RollGuiDown( $hWnd )
Global $hRollGuiUp
  DllCall( $dllUser32, "int", "AnimateWindow", "hwnd", $hGUI, "int", 200, "long", "0x20005" )
WinActivate( $hWnd )
GUIDelete( $hRollGuiUp )
$fGuiRolledUp = 0
EndFunc

LarsJ

1 person likes this

Share this post


Link to post
Share on other sites



That's quite neat. I like the idea someone had to use a tiny toolwindow for the shrunken window, I might well think of that myself before too long.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0