如何改变窗体(form)的形状, 我想把一张圆形图片贴在窗体上, 窗体变为该圆形, 而不是四四方方的窗体。 如何改变窗体(form)的形状, 我想把一张圆形图片贴在窗体上, 窗体变为该圆形, 而不是四四方方的窗体。如题。请各位帮忙,或给几行代码参考。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 www.CodeProject.com 上有你想要的东东。上去找一下。 http://www.chenjiliang.com/Article/View.aspx?ArticleID=373&TypeID=79 Bitmap bit = new Bitmap("Bg.gif"); protected override void OnPaint(PaintEventArgs e) { //bit.MakeTransparent(Color.White); this.Width = bit.Width; this.Height = bit.Height; e.Graphics.DrawImage((Image)bit, new Point(0, 0)); } 椭圆形窗体,改一下就行 private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {//创建椭圆形窗体 //创建一个路径对象 GraphicsPath MyPath=new GraphicsPath(); //将椭圆添加到路径对象中 MyPath.AddEllipse(20,30,this.Width-30,this.Height-40); //使用椭圆构造一个区域,并将此区域作为程序窗体区域 this.Region=new Region(MyPath); } Bg.gif 就是你要的形状的图片form1的属性设置 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(499, 376); this.ControlBox = false; this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form1"; this.TransparencyKey = System.Drawing.SystemColors.Control; this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); this.ResumeLayout(false); this.PerformLayout(); 把窗体背景设成某一个颜色例如this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(128)));放一个pictureBox在窗体里,并设置图片设置透明颜色为窗体背景颜色this.TransparencyKey = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(128)));应该能完成你所要的效果,这些都在窗体 属性 里面能直接选择 先声明System.Drawing.Drawing2D;以下代码可直接复制到窗体的构造函数中 public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // }代码为:GraphicsPath gp = new GraphicsPath();gp.AddEllipse(0, 0, 120, 120);Region r = new Region(gp);this.Region = r; 如何生成没有边框的窗体将窗体的FormBorderStyle设置为None即可 .. 很多年前就开始有API 版的了现在已经改版了用 .net 的 Drawing 做了. 关于泛型 如何判断前后两个值,相等的话就合并 后台能控制 div中的显示内容吗? 简单而高难的RowHeader处理 c#关于打印的问题 高手请进 帮我看下 具体哪里出问题了 在C#中可以用ACTIVE SKIN伐?可以的话怎么用啊?谢谢 C# 新手 关于时间问题 怎么判断键盘上 两个键(比如说a和b)同时按下 转换成中文时的"?"怎么解决。 菜鸟问个datarow的问题 关于asp.net模板
{
//bit.MakeTransparent(Color.White);
this.Width = bit.Width;
this.Height = bit.Height;
e.Graphics.DrawImage((Image)bit, new Point(0, 0));
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{//创建椭圆形窗体
//创建一个路径对象
GraphicsPath MyPath=new GraphicsPath();
//将椭圆添加到路径对象中
MyPath.AddEllipse(20,30,this.Width-30,this.Height-40);
//使用椭圆构造一个区域,并将此区域作为程序窗体区域
this.Region=new Region(MyPath);
}
form1的属性设置 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(499, 376);
this.ControlBox = false;
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form1";
this.TransparencyKey = System.Drawing.SystemColors.Control;
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
this.ResumeLayout(false);
this.PerformLayout();
以下代码可直接复制到窗体的构造函数中
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
代码为:
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(0, 0, 120, 120);
Region r = new Region(gp);
this.Region = r; 如何生成没有边框的窗体
将窗体的FormBorderStyle设置为None即可