如何实现渐进透明的 WinForm 窗体? 参考:http://dev.csdn.net/develop/article/18/18774.shtm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void Login_Load(object sender, System.EventArgs e) //Form的Load事件 { for(double d=0d; d< 1.0d; d+=0.1d) { System.Threading.Thread.Sleep(50); Application.DoEvents(); this.Opacity=d; this.Refresh(); } } 这个好说,给你一个代码如下:在窗体的Load时加入如下的代码:this.TransparencyKey = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));为窗体的Paint添加事件: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0,0),new Point(this.Width,this.Height),System.Drawing.Color.FromArgb(255, 192, 192),System.Drawing.Color.FromArgb(255, 192, 180)); e.Graphics.FillRectangle(p,0,0,this.Width,this.Height); } 每一个窗体都有这个属性Opacity=x%。在LOAD事件中,逐步改变百分比就行啦。 再给你一个,代码如下: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height),System.Drawing.Color.FromArgb(255, 128, 9),System.Drawing.Color.FromArgb(255, 128, 0),0,true); e.Graphics.FillRectangle(p,0,0,this.Width,this.Height); } private void Form1_Load(object sender, System.EventArgs e) { this.TransparencyKey = System.Drawing.Color.FromArgb(255, 128, 0); } 原理一样,使用定时器实现一个窗体,在弹出时要慢慢从透明到不透明的特效 private double opacityIncrement = 0.1; private const int changeInterval = 25; private Timer timer1; //表单载入 private void Form1_Load(object sender, System.EventArgs e) { timer1=new Timer(); timer1.Interval=changeInterval; timer1.Tick+=new System.EventHandler(this.timer1_Tick); this.Opacity=0; timer1.Start(); } //渐显事件 private void timer1_Tick(object sender, System.EventArgs e) { this.timer1.Stop(); if(this.Opacity<1) { this.Opacity=this.Opacity+this.changeInterval; } else { this.timer1.Enabled=false; } this.timer1.Start(); } C# 怎么获取所有打开的窗体(包括隐藏的窗体) 正则表达式 关于linkbutton 和 button 的问题 如何在存储过程中使用查询语句的结果 做一个网络应用程序 急需帮助 放血,有关隐形重写Show、Showdialog方法的技巧(win窗体权限判断) [winform]Datagrid中CheckedBox选择问题?? 一个DATAVIEW dv怎么通过dv.RowFilter筛选形成一个新的DATAVIEW DW 如何把SQL中char字段内容读到string变量中去,怎么转换 有没有自定义类型的数组 DataGrid编辑更新数据问题,请各位高手指点!
for(double d=0d; d< 1.0d; d+=0.1d)
{
System.Threading.Thread.Sleep(50);
Application.DoEvents();
this.Opacity=d;
this.Refresh();
}
}
this.TransparencyKey = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));为窗体的Paint添加事件:
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0,0),new Point(this.Width,this.Height),System.Drawing.Color.FromArgb(255, 192, 192),System.Drawing.Color.FromArgb(255, 192, 180));
e.Graphics.FillRectangle(p,0,0,this.Width,this.Height);
}
在LOAD事件中,逐步改变百分比就行啦。
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height),System.Drawing.Color.FromArgb(255, 128, 9),System.Drawing.Color.FromArgb(255, 128, 0),0,true);
e.Graphics.FillRectangle(p,0,0,this.Width,this.Height);
} private void Form1_Load(object sender, System.EventArgs e)
{
this.TransparencyKey = System.Drawing.Color.FromArgb(255, 128, 0);
}
实现一个窗体,在弹出时要慢慢从透明到不透明的特效
private double opacityIncrement = 0.1;
private const int changeInterval = 25;
private Timer timer1; //表单载入
private void Form1_Load(object sender, System.EventArgs e)
{ timer1=new Timer();
timer1.Interval=changeInterval;
timer1.Tick+=new System.EventHandler(this.timer1_Tick);
this.Opacity=0;
timer1.Start();
} //渐显事件
private void timer1_Tick(object sender, System.EventArgs e)
{
this.timer1.Stop();
if(this.Opacity<1)
{
this.Opacity=this.Opacity+this.changeInterval;
}
else
{
this.timer1.Enabled=false;
}
this.timer1.Start();
}