//窗体关闭时 protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); //在Form_FormClosing中添加代码实现窗体的淡出 FormWin32.AnimateWindow(this.Handle, 800, FormWin32.AW_BLEND | FormWin32.AW_HIDE); }
//Show或Hide被调用时 protected override void OnVisibleChanged(EventArgs e) { if (Visible) { //启用窗口淡入淡出 if (!DesignMode) { //淡入特效 FormWin32.AnimateWindow(this.Handle, 800, FormWin32.AW_BLEND | FormWin32.AW_ACTIVATE); } //判断不是在设计器中 base.OnVisibleChanged(e); } else { base.OnVisibleChanged(e); FormWin32.AnimateWindow(this.Handle, 800, FormWin32.AW_BLEND | FormWin32.AW_HIDE); } }