1 启动窗体的动画效果
使用AnimateWindow制作淡入淡出效果的窗体
Code
1 [DllImportAttribute("user32.dll")]
2 private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
3
4 //dwflag的取值如下
5 public const Int32 AW_HOR_POSITIVE = 0x00000001; //从左到右显示
6 public const Int32 AW_HOR_NEGATIVE = 0x00000002; //从右到左显示
7 public const Int32 AW_VER_POSITIVE = 0x00000004; //从上到下显示
8 public const Int32 AW_VER_NEGATIVE = 0x00000008; //从下到上显示
9 public const Int32 AW_CENTER = 0x00000010; //若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
10 public const Int32 AW_HIDE = 0x00010000; //隐藏窗口,缺省则显示窗口
11 public const Int32 AW_ACTIVATE = 0x00020000; //激活窗口。在使用了AW_HIDE标志后不能使用这个标志
12 public const Int32 AW_SLIDE = 0x00040000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
13 public const Int32 AW_BLEND = 0x00080000; //透明度从高到低
14
在Load中:
1 AnimateWindow(this.Handle, 3000, AW_BLEND + AW_CENTER);
在FormClosing中:
1 AnimateWindow(this.Handle, 500, AW_SLIDE + AW_VER_POSITIVE + AW_HIDE);
2 窗体圆角效果
Code
1 private void Type(Control sender, int p_1, double p_2)
2 {
3 GraphicsPath oPath = new GraphicsPath();
4 oPath.AddClosedCurve(
5 new Point[] {
6 new Point(0, sender.Height / p_1),
7 new Point(sender.Width / p_1, 0),
8 new Point(sender.Width - sender.Width / p_1, 0),
9 new Point(sender.Width, sender.Height / p_1),
10 new Point(sender.Width, sender.Height - sender.Height / p_1),
11 new Point(sender.Width - sender.Width / p_1, sender.Height),
12 new Point(sender.Width / p_1, sender.Height),
13 new Point(0, sender.Height - sender.Height / p_1) },
14 (float)p_2);
15 sender.Region = new Region(oPath);
16 }
17
18 private void frmFalsh_Paint(object sender, PaintEventArgs e)
19 {
20 Type(this, 25, 0.1);
21 }
22
23 private void frmFalsh_Resize(object sender, EventArgs e)
24 {
25 Type(this, 25, 0.1);
26 }