Generally, when we start an application, the normal application window is instantly displayed on the screen. Have you ever imagined that when you open an application, the display of the window is as unpredictable and colorful as the slide? You may not be able to make a presentable, but at least entertain yourself.
Okay, let's get to the point: you can now imagine a screen that, when you start an application, has a small dot in the center of the display, and then it gets bigger and expands around until the window is all displayed. And when you close it, it goes from top to bottom and slowly disappears from the monitor .... What effect would that be? Hehe, if you like, follow me to complete such a great dream.
What is the design idea? If you're smart, you'll soon realize that the project is likely to use Windows to provide APIs. On the Internet, there is a function: AnimateWindow, it can achieve the animation effect of the form. So the rest of the work is to check out MSDN for more information about the AnimateWindow function.
The following is a detailed introduction to the application of AnimateWindow function in C # in this example.
Declaration mode:
声明
[DllImportAttribute("user32.dll")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
Parameter description:
Code
(1). IntPtr hwnd: 目标窗口 的句柄对象, 一般为 this.Handle
(2). int dwTime: 动画的持续时间, 数值越大动 画效果的时间越长
(3). int dwFlags: 动画效果类型选项, 在C#中声明如下:
注: 您程序中只声明需要的动画类型即可, 关于每个参数的含义会在后面详细说明
public const Int32 AW_HOR_POSITIVE = 0x00000001;
public const Int32 AW_HOR_NEGATIVE = 0x00000002;
public const Int32 AW_VER_POSITIVE = 0x00000004;
public const Int32 AW_VER_NEGATIVE = 0x00000008;
public const Int32 AW_CENTER = 0x00000010;
public const Int32 AW_HIDE = 0x00010000;
public const Int32 AW_ACTIVATE = 0x00020000;
public const Int32 AW_SLIDE = 0x00040000;
public const Int32 AW_BLEND = 0x00080000;