以下是一段使用api的窗口特效代码,小测一把看是不是在窗口显示的时候会显示各种特殊效果,实践出真理!
[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;//透明渐变显示效果
private void Form1_Load(object sender, System.EventArgs e)
{
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_FormClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_HIDE | AW_VER_NEGATIVE);
}
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2009/09/09/1563026.html,如需转载请自行联系原作者