[System.Runtime.InteropServices.DllImport("user32")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
private const int AW_HOR_POSITIVE = 0x0001;//从左向右显示
private const int AW_HOR_NEGATIVE = 0x0002;//从右向左显示
private const int AW_VER_POSITIVE = 0x0004;//从上到下显示
private const int AW_VER_NEGATIVE = 0x0008;//从下到上显示
private const int AW_CENTER = 0x0010;//从中间向四周
private const int AW_HIDE = 0x10000;
private const int AW_ACTIVATE = 0x20000;//普通显示
private const int AW_SLIDE = 0x40000;
private const int AW_BLEND = 0x80000;//透明渐变显示
void texiao()
{
int animatetype = 10;
Random a = new Random();
int dwFlags = (int)a.Next(animatetype);
switch (dwFlags)
{
case 0://普通显示
AnimateWindow(Handle, 1000, AW_ACTIVATE);
break;
case 1://从左向右显示
AnimateWindow(Handle, 1000, AW_HOR_POSITIVE);
break;
case 2://从右向左显示
AnimateWindow(Handle, 1000, AW_HOR_NEGATIVE);
break;
case 3://从上到下显示
AnimateWindow(Handle, 1000, AW_VER_POSITIVE);
break;
case 4://从下到上显示
AnimateWindow(Handle, 1000, AW_VER_NEGATIVE);
break;
case 5://透明渐变显示
AnimateWindow(Handle, 1000, AW_BLEND);
break;
case 6://从中间向四周
AnimateWindow(Handle, 1000, AW_CENTER);
break;
case 7://左上角伸展
AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_POSITIVE);
break;
case 8://左下角伸展
AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_NEGATIVE);
break;
case 9://右上角伸展
AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_POSITIVE);
break;
case 10://右下角伸展
AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_NEGATIVE);
break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
texiao();}