本文实例分析了Winform窗体效果。分享给大家供大家参考。具体如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication4 { public partial class Form3 : Form { bool flag = false ; public Form3() { InitializeComponent(); flag = true ; } #region user32.dll //导入user32.dll [System.Runtime.InteropServices.DllImport( "user32" )] //声明API函数 private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); #endregion #region 常量 //正面_水平方向 const int AW_HOR_POSITIVE = 0x0001; //负面_水平方向 const int AW_HOR_NEGATIVE = 0x0002; //正面_垂直方向 const int AW_VER_POSITIVE = 0x0004; //负面_垂直方向 const int AW_VER_NEGATIVE = 0x0008; //由中间四周展开或 const int AW_CENTER = 0x0010; //隐藏对象 const int AW_HIDE = 0x10000; //显示对象 const int AW_ACTIVATE = 0x20000; //拉幕滑动效果 const int AW_SLIDE = 0x40000; //淡入淡出渐变效果 const int AW_BLEND = 0x80000; #endregion #region 判断方向 public int IsHorOrVer( int pos) { int rtn = 0; //判断是正方向还是反方向 if (pos.Equals(0)) { //判断是横向还是纵向 if (flag) rtn = AW_HOR_POSITIVE; else rtn = AW_VER_POSITIVE; } else if (pos.Equals(1)) { //判断是横向还是纵向 if (flag) rtn = AW_HOR_NEGATIVE; else rtn = AW_VER_NEGATIVE; } return rtn; } #endregion private void button1_Click( object sender, EventArgs e) { //动画——窗体向上拖拉 AnimateWindow( this .Handle, 1000, AW_SLIDE | AW_HIDE | IsHorOrVer(1)); //动画——窗体向下拖拉 AnimateWindow( this .Handle, 1000, AW_SLIDE | AW_ACTIVATE | IsHorOrVer(0)); //动画——窗体淡出特效 AnimateWindow( this .Handle, 1000, AW_BLEND | AW_HIDE | IsHorOrVer(1)); //动画——窗体淡入特效 AnimateWindow( this .Handle, 1000, AW_BLEND | AW_ACTIVATE | IsHorOrVer(0)); //动画——窗体由四周向中心缩小直至消失 AnimateWindow( this .Handle, 1000, AW_CENTER | AW_HIDE | IsHorOrVer(1)); //动画——窗体由中心向四周扩展 AnimateWindow( this .Handle, 1000, AW_CENTER | AW_ACTIVATE | IsHorOrVer(0)); } } } |
希望本文所述对大家的C#程序设计有所帮助。