定义公共变量
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; //使用淡入效果
声明AnimateWindow函数
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
运用API
AnimateWindow(this.Handle, 2000, AW_HOR_POSITIVE); //自左向右滚动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_SLIDE + AW_HOR_POSITIVE); //自左向右滑动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_HOR_NEGATIVE); //自右向左滚动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_SLIDE + AW_HOR_NEGATIVE); //自右向左滑动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_VER_POSITIVE); //自上向下滚动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_SLIDE + AW_VER_POSITIVE); // 自上向下滑动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_VER_NEGATIVE);//自下向上滚动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_SLIDE + AW_VER_NEGATIVE); //自下向上滑动窗体动画效果
AnimateWindow(this.Handle, 2000, AW_SLIDE + AW_CENTER); // 向外扩展窗体动画效果
AnimateWindow(this.Handle, 2000, AW_BLEND); //淡入窗体动画效果