通常我们的窗口都是正方形,或长方形的,如何做不规则窗体呢?参照外国一些BLOG,主要是修改OnPaint函数,
另外注意使窗体的背景色与transparancyKey 的色一样.下面附一些代码,希望能给你带来帮助.
protected override void OnPaint(PaintEventArgs e)
{
Graphics grfx = e.Graphics;
grfx.SmoothingMode = SmoothingMode.HighQuality;
GraphicsPath grfxPath1 = new GraphicsPath();
Rectangle rec1 = new Rectangle(0,0,300,100);
grfxPath1.AddEllipse(rec1);
Rectangle rec2 = new Rectangle(120,99,60,40);
grfxPath1.AddEllipse(rec2);
grfx.SetClip(grfxPath1,CombineMode.Replace);
Brush b = new SolidBrush(Color.Green);
grfx.FillEllipse(b,rec1);
grfx.FillEllipse(b,rec2);
// Rectangle frmRectangle = new Rectangle(0,0,this.Width,this.Height);
// grfx.DrawImage(Image.FromFile("zerosones.jpg"), frmRectangle);
// then we may make a border to our from by using a thick pen
Pen p = new Pen(Color.Yellow,5f);
grfx.DrawPath(p,grfxPath1);
}