public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
AnimateWindow(this.Handle, 300, AW_BLEND + AW_VER_NEGATIVE);//初始化时候调用
this.FormClosed += new FormClosedEventHandler(Form2_FormClosed);
}
void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
AnimateWindow(this.Handle, 300, AW_BLEND + AW_VER_NEGATIVE + AW_HIDE); //关闭WinForm时候调用
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
//hwmd 窗口句柄 dwTime动画持续时间 DwFlags参数选项
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;
}今天我开始写Blog咯,呵呵!
实现窗口的淡入淡出效果,要调用WINDOWS提供的API函数,不知道.NET类库有没有提供这样的函数!


浙公网安备 33010602011771号