#region 关闭窗体特效
//导入user32.dll
[System.Runtime.InteropServices.DllImport("user32")]
//声明API函数
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;
#endregion
然后再关闭窗体前加以下代码:
AnimateWindow(this.Handle, 1000, AW_CENTER | AW_HIDE | AW_HOR_NEGATIVE);