Share this page 

Animate a WindowTag(s): WinAPI/Registry


Starting with Win98, a new API is available to add a special effect to your application. The AnimateWindow() is very easy to use, you simply need to pass your window's handle, a delay and some flags to specify the desired effect. These effects are designed to enhance the opening or closing of a window.
[local function declaration]
FUNCTION boolean AnimateWindow( long lhWnd, long lTm, long lFlags) &
  LIBRARY 'user32'
  
[instance variable]  
CONSTANT LONG AW_HOR_POSITIVE = 1
CONSTANT LONG AW_HOR_NEGATIVE = 2
CONSTANT LONG AW_VER_POSITIVE = 4
CONSTANT LONG AW_VER_NEGATIVE = 8
CONSTANT LONG AW_CENTER = 16
CONSTANT LONG AW_HIDE = 65536
CONSTANT LONG AW_ACTIVATE = 131072
CONSTANT LONG AW_SLIDE = 262144
CONSTANT LONG AW_BLEND = 524288  

[powerscript, open event]
// slide right to left
AnimateWindow ( Handle( this ),500,AW_HOR_NEGATIVE) 

// slide left to right
AnimateWindow ( Handle( this ),500,AW_HOR_POSITIVE)

// slide top to bottom
AnimateWindow ( Handle( this ),500,AW_VER_POSITIVE)

// slide bottom to top
AnimateWindow ( Handle( this ),500,AW_VER_NEGATIVE)

// from center expand
AnimateWindow ( Handle( this ),500,AW_CENTER)

// reveal diagonnally
AnimateWindow ( Handle( this ),500,AW_VER_NEGATIVE + AW_HOR_NEGATIVE)
Here some notes about the flags (from MSDN)
AW_SLIDE    Uses slide animation. 
            By default, roll animation is used. 
            This flag is ignored when used with the AW_CENTER flag.  
AW_ACTIVATE Activates the window. Do not use this flag with AW_HIDE.  
AW_BLEND    Uses a fade effect. 
            This flag can be used only if hwnd is a top-level window.  
AW_HIDE     Hides the window. By default, the window is shown.  
AW_CENTER   Makes the window appear to collapse inward 
            if the AW_HIDE flag is used or expand outward 
            if the AW_HIDE flag is not used.  
AW_HOR_POSITIVE Animates the window from left to right. 
                This flag can be used with roll or slide animation.
                It is ignored when used with the AW_CENTER flag. 
AW_HOR_NEGATIVE Animates the window from right to left. 
                This flag can be used with roll or slide animation. 
                It is ignored when used with the AW_CENTER flag. 
AW_VER_POSITIVE Animates the window from top to bottom. 
                This flag can be used with roll or slide animation.
                It is ignored when used with the AW_CENTER flag.  
AW_VER_NEGATIVE Animates the window from bottom to top. 
                This flag can be used with roll or slide animation. 
                It is ignored when used with the AW_CENTER flag.