Non Rectangular Forms
Have you ever wondered how you can create nonrectangular forms? Windows Media Player is a good example. When you switch to different skins, the border changes shapes. It seems like quite a difficult task, but it ends up being extremely simple. It's really only a few lines of code! But these few lines of code can make a big difference in the visual impression your project creates.
First create a new Windows Forms project using C#. (This can be done in any .NET language, but we'll use C# for this example.) Add a button to the middle of the form. Add this code to the button:
private void button1_Click(object sender, System.EventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
int width = this.ClientSize.Width;
int height = this.ClientSize.Height;
p.AddClosedCurve(new Point[]{new Point(width/2, height/10),
new Point(width,0), new Point(width, height/3),
new Point(width-width/3, height),
new Point(width/7, height-height/} );
this.Region = new Region(p);
}
__________________
Ravi-the Sun
Think Bright,Think Sun
www.ravithesun.c-o.in My Blog
www.sunsoft.c-o.in My Web Home
|