AnimateWindow function
Advanced GDI routines
Return to Introduction  Previous page  Next page
Unit
acGraphics  

Declaration
function AnimateWindow(  
   hWnd: HWND;     // handle to window  
   dwTime: DWORD;  // duration of animation  
   dwFlags: DWORD  // animation type  
): BOOL;  

Description
The AnimateWindow function enables you to produce special effects when showing or hiding windows. There are three types of animation: roll, slide, and alpha-blended fade.

Parameters
hwnd  
Handle to the window to animate. The calling thread must own this window.  
dwTime  
Specifies how long it takes to play the animation, in milliseconds. Typically, an animation takes 200 milliseconds to play.  
dwFlags  
Specifies the type of animation. This parameter can be one or more of the following values.  
 
Value   Description  
AW_SLIDEUses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.  
AW_ACTIVATEActivates the window. Do not use this value with AW_HIDE.  
AW_BLENDUses a fade effect. This flag can be used only if hwnd is a top-level window. tip This effect works on Win2000 or later.  
AW_HIDEHides the window. By default, the window is shown.  
AW_CENTERMakes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used.  
AW_HOR_POSITIVEAnimates the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.  
AW_HOR_NEGATIVEAnimates the window from right to left. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.  
AW_VER_POSITIVEAnimates the window from top to bottom. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.  
AW_VER_NEGATIVEAnimates the window from bottom to top. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.  

Return Values
If the function succeeds, the return value is nonzero.  
 
If the function fails, the return value is zero. The function will fail in the following situations:  
·The window uses the window region.  
·The window is already visible and you are trying to show the window.  
·The window is already hidden and you are trying to hide the window.  
 
To get extended error information, call the GetLastError function.  

Remarks
You can combine AW_HOR_POSITIVE or AW_HOR_NEGATIVE with AW_VER_POSITIVE or AW_VER_NEGATIVE to animate a window diagonally.  
 
The window procedures for the window and its child windows may need to handle any WM_PRINT or WM_PRINTCLIENT messages. Dialog boxes, controls, and common controls already handle WM_PRINTCLIENT. The default window procedure already handles WM_PRINT.  

Requirements
Windows NT/2000: Requires Windows 2000 or later.  
Windows 95/98: Requires Windows 98 or later.  
 
tip If you call this function on Win95, or on Win98 with AW_BLEND parameter — nothing happends.  

Example
procedure TForm1.FormShow(Sender: TObject);  
var  
  I: Integer;  
begin  
  AnimateWindow(Handle, 300, AW_HOR_POSITIVE + AW_VER_POSITIVE + AW_SLIDE + AW_ACTIVATE);  
end;  

See also
acAnimateWindow function and acWin2kEffects component.