[System.Runtime.InteropServices.DllImport("user32")]
private static extern bool AnimateWindow(IntPtr hwnd,int dwTime, int dwFlags);
const int AW_HOR_POSITIVE = 0x0001;
const int AW_HOR_NEGATIVE = 0x0002;
const int AW_VER_POSITIVE = 0x0004;
const int AW_VER_NEGATIVE = 0x0008;
const int AW_CENTER = 0x0010;
const int AW_HIDE = 0x10000;
const int AW_ACTIVATE = 0x20000;
const int AW_SLIDE = 0x40000;
const int AW_BLEND = 0x80000;
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_HIDE | AW_VER_NEGATIVE);
}
Syntax
BOOL AnimateWindow(HWND hwnd,DWORD dwTime,DWORD dwFlags);
Parameters
hwnd
- [in] Handle to the window to animate. The calling thread must own this window.
dwTime- [in] Specifies how long it takes to play the animation, in milliseconds. Typically, an animation takes 200 milliseconds to play.
dwFlags- [in] Specifies the type of animation. This parameter can be one or more of the following values. Note that, by default, these flags take effect when showing a window. To take effect when hiding a window, use AW_HIDE and a logical OR operator with the appropriate flags.
AW_SLIDE
- Uses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.
AW_ACTIVATE- Activates the window. Do not use this value 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 AW_HIDE is used or expand outward if the AW_HIDE is not used. The various direction flags have no effect.
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 AW_CENTER or AW_BLEND.
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 AW_CENTER or AW_BLEND.
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 AW_CENTER or AW_BLEND.
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 AW_CENTER or AW_BLEND.