2012年2月29日星期三

制作半透明渐显窗体

Frm_Main.cs

View Code
 1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8
9 namespace GraduallyForm
10 {
11 public partial class Frm_Main : Form
12 {
13 public Frm_Main()
14 {
15 InitializeComponent();
16 }
17
18 private void timer1_Tick(object sender, EventArgs e)
19 {
20 this.Opacity += 0.1;//设置窗体的不透明级别
21 }
22 }
23 }

Frm_Main.designer.cs

View Code
 1 namespace GraduallyForm
2 {
3 partial class Frm_Main
4 {
5 /// <summary>
6 /// 必需的设计器变量。
7 /// </summary>
8 private System.ComponentModel.IContainer components = null;
9
10 /// <summary>
11 /// 清理所有正在使用的资源。
12 /// </summary>
13 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
14 protected override void Dispose(bool disposing)
15 {
16 if (disposing && (components != null))
17 {
18 components.Dispose();
19 }
20 base.Dispose(disposing);
21 }
22
23 #region Windows 窗体设计器生成的代码
24
25 /// <summary>
26 /// 设计器支持所需的方法 - 不要
27 /// 使用代码编辑器修改此方法的内容。
28 /// </summary>
29 private void InitializeComponent()
30 {
31 this.components = new System.ComponentModel.Container();
32 this.timer1 = new System.Windows.Forms.Timer(this.components);
33 this.button1 = new System.Windows.Forms.Button();
34 this.SuspendLayout();
35 //
36 // timer1
37 //
38 this.timer1.Enabled = true;
39 this.timer1.Interval = 1000;
40 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
41 //
42 // button1
43 //
44 this.button1.Location = new System.Drawing.Point(500, 338);
45 this.button1.Name = "button1";
46 this.button1.Size = new System.Drawing.Size(47, 25);
47 this.button1.TabIndex = 0;
48 this.button1.Text = "button1";
49 this.button1.UseVisualStyleBackColor = true;
50 //
51 // Frm_Main
52 //
53 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
54 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
55 this.BackgroundImage = global::GraduallyForm.Properties.Resources.C_编程词典;
56 this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
57 this.ClientSize = new System.Drawing.Size(404, 253);
58 this.Controls.Add(this.button1);
59 this.Name = "Frm_Main";
60 this.Opacity = 0.3;
61 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
62 this.Text = "制作半透明渐显窗体";
63 this.ResumeLayout(false);
64
65 }
66
67 #endregion
68
69 private System.Windows.Forms.Timer timer1;
70 private System.Windows.Forms.Button button1;
71 }
72 }



作者:王雄飞(当冬夜渐暖)
出处:http://www.cnblogs.com/ynbt/
关于作者:专注于.Net、WCF和移动互联网开发。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题,可以通过ynbt_wang@163.com联系我,非常感谢。 。
制作半透明渐显窗体

TAG: