如何改变窗体(form)的形状, 我想把一张圆形图片贴在窗体上, 窗体变为该圆形, 而不是四四方方的窗体。
如题。
请各位帮忙,或给几行代码参考。

解决方案 »

  1.   

    www.CodeProject.com 上有你想要的东东。上去找一下。
      

  2.   

    http://www.chenjiliang.com/Article/View.aspx?ArticleID=373&TypeID=79
      

  3.   

                     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));
            }
      

  4.   

    椭圆形窗体,改一下就行
    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);
    }
      

  5.   

    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();
      

  6.   

    把窗体背景设成某一个颜色例如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)));应该能完成你所要的效果,这些都在窗体 属性 里面能直接选择
      

  7.   

    先声明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即可
      

  8.   

    .. 很多年前就开始有API 版的了现在已经改版了用 .net 的 Drawing 做了.