See othersProgramThis API is used. Learn more. Animatewindow is mainly used to implement window animation. ViewCode.
Using System. runtime. interopservices;
Namespace User32animatewindowapi
{
Public Partial Class Form1: Form
{
/// <Summary>
/// Window animation effect method.
/// </Summary>
/// <Param name = "whnd"> Handle of the window that generates the animation </Param>
/// <Param name = "dwtime"> The animation duration (in microseconds) is 200 microseconds. </Param>
/// <Param name = "dwflag"> Animation type </Param>
/// <Returns> </returns>
[Dllimport ( " USER32 " )]
Private Static Extern Bool Animatewindow (intptr whnd, Int Dwtime, Int Dwflag );
# Region Animation type
// Left to right
Public Const Int32 aw_hor_positive = Zero X 00000001 ;
// From right to left
Public Const Int32 aw_hor_negative = Zero X 00000002 ;
// From top to bottom
Public Const Int32 aw_ver_positive = Zero X 00000004 ;
// From bottom to top
Public Const Int32 aw_ver_negative = Zero X 00000008 ;
// From center to four weeks
Public Const Int32 aw_center = Zero X 00000010 ;
// Hide window
Public Const Int32 aw_hide = Zero X 00010000 ;
// Fade in and fade out
Public Const Int32 aw_blend = Zero X 00080000 ;
// Display window
Public Const Int32 aw_activate = Zero X 00020000 ;
# Endregion
Public Form1 ()
{
Initializecomponent ();
}
Private Void Form1_load ( Object Sender, eventargs E)
{
// Call
Animatewindow ( This. Handle,3000, Aw_center| Aw_activate );
}
}
}
Description of the animatewindow function:
Function: this function can display and hide windows with special effects. There are two types of animation effects: Scroll animation and slide animation.
Function prototype: bool animatewindow (hwnd, DWORD dwtime, DWORD dwflags );
Parameters:
Hwnd: Specifies the handle of the window that generates the animation.
Dwtime: Specifies the animation duration (in microseconds). The standard time for completing an animation is 200 microseconds.
Dwfags: Specifies the animation type. This parameter can be a combination of one or more of the following labels. Description:
Aw_slide: Use the slide type. The default value is the scroll animation type. When the aw_center flag is used, this flag is ignored.
Aw_active: Activation window. Do not use this flag after the aw_hide flag is used.
Aw_blend: fade out effect. This flag can be used only when hwnd is a top-level window.
Aw_hide: hides the window. The window is displayed by default.
Aw_center: If the aw_hide flag is used, the window will overlap inward. If the aw_hide flag is not used, the window will expand outward.
Aw_hor_positive: the window is displayed from left to right. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored.
Aw_hor_negative: the window is displayed from right to left. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored.
Aw_ver_positive: the window is displayed from top to bottom. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored.
Aw_ver_negative: the window is displayed from bottom to top. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored.
Return Value: If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. The function will fail in the following cases:
The window uses the window boundary. The window is visible, and the window is hidden. To obtain more error information, call the getlasterror function.
Note: 1) You can combine aw_hor_positive or aw_hor_negtve with aw_ver_positve or aw_ver_negative to activate a window.
2) wm_print or wm_printclient messages may need to be processed in the window process of the window and Its subwindow. The dialog box, control, and sharing control processes wm_printclient messages, and wm_print messages are also processed in the default window process.