Original address: http://blog.csdn.net/a237428367/article/details/5933565
Using System.runtime.interopservices;public class Win32 {public Const Int32 aw_hor_positive = 0x0000000 1; Open window from left to right public const Int32 aw_hor_negative = 0x00000002; Open window from right to left public const Int32 aw_ver_positive = 0x00000004; Open window from top to bottom public const Int32 aw_ver_negative = 0x00000008; Open window from bottom to top Public const Int32 aw_center = 0x00000010; Public Const Int32 Aw_hide = 0x00010000; If you want to use this function when the form is unloaded, add this constant public const Int32 aw_activate = 0x00020000; After the form is opened by this function, the focus is lost by default unless the public const INT32 Aw_slide = 0x00040000 is added to this constant; Public Const Int32 Aw_blend = 0x00080000; Fade effect [DllImport ("user32.dll", CharSet = CharSet.Auto)] public static extern bool AnimateWindow ( INTPTR hwnd,//Handle to Window int dwtime,//duration of animation int Dwflag S//animation type); }/* Fade inform */private void Form_Load (object sender, EventArgs e) {Win32.animatewindow (this. Handle, win32.aw_blend);} /* Fade out form */private void Form_formclosing (object sender, FormClosingEventArgs e) {Win32.animatewindow (this. Handle, Win32.aw_slide | Win32.aw_hide | Win32.aw_blend);}
(go) WinForm Form fade effect