Click here to Skip to main content
Click here to Skip to main content
Go to top

Irregular Shaped Form

, 17 Jan 2006
Rate this:
Please Sign up or sign in to vote.
How to customize your form shape and control shapes according to your needs.


I get sick of the standard form shapes. I needed to customize my form shape according to my needs. Not only the form shape, but also any control shape. What about having a circle button or a triangle button? The implementation of all this will be described in easy steps, in this article. First I will start with the required technology.


Applications use paths to draw outlines of shapes, fill the interiors of shapes, and create clipping regions. The graphics engine maintains the coordinates of geometric shapes in a path in world coordinate space. A path may be composed of any number of figures (sub paths). Each figure is either composed of a sequence of connected lines and curves, or a geometric shape primitive. The starting point of a figure is the first point in the sequence of connected lines and curves. The ending point is the last point in the sequence.


  • Namespace: System.Drawing.Drawing2D


A region is scalable because its coordinates are specified in world coordinates. On a drawing surface, however, its interior is dependent on the size and shape of the pixels representing it. An application can use regions to clamp the output of drawing operations. The window manager uses regions to define the drawing area of windows. These regions are called clipping regions. An application can also use regions in hit-testing operations, such as checking whether a point or a rectangle intersects a region. An application can fill a region by using a Brush object.


Simply start the application, right click to choose the form background. After you choose the background right, click and select "DrawPath". Start clicking on the form drawing your path. Finally, select "Redraw form" and you will have your form shaped.

The Code

Drawing path points:

private void menuItem2_Click(object sender, 
                            System.EventArgs e)

private void Form1_MouseDown(object sender, 
             System.Windows.Forms.MouseEventArgs e)
    //    Select the path point
        g= this.CreateGraphics();
        p=new Pen(Color.Black);
        Point pont=new Point(0,0);
            for(int j=PontNum;j<1000;j++)

Redraw Form:

private void menuItem3_Click(object sender, System.EventArgs e)
    GraphicsPath NewPth=new GraphicsPath();
    this.Region = new Region(NewPth);

Moving the Form:

private void Form1_MouseDown(object sender, 
              System.Windows.Forms.MouseEventArgs e)

private void Form1_MouseUp(object sender, 
             System.Windows.Forms.MouseEventArgs e)
private void Form1_MouseMove(object sender, 
             System.Windows.Forms.MouseEventArgs e)


I think this is a good base to customize your form shape and shape of other controls in your application. A more practical way to use it is like what we did for the button. You may use this code to get your path points, then add it in the form load of your application. Hope it could be useful. All comments about this are welcome.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Egypt Egypt
No Biography provided

Comments and Discussions

GeneralMy vote of 5 Pinmembermanoj kumar choubey4-Apr-12 23:49 
GeneralTransparent Form and windows media player Pinmemberdivyesh143220-Jun-08 21:06 
General[Message Deleted] Pinmembermyventsi28-Nov-07 9:01 
GeneralRe: Where can i find DrawPath ??? Pinmembershabonaa28-Nov-07 11:02 
QuestionJust a quick question ... Pinmemberb0ksah12-Feb-07 1:02 
AnswerRe: Just a quick question ... Pinmembershabonaa13-Feb-07 21:15 
Questiontext shape form? PinmemberJaamsadams30-Jan-06 15:20 
AnswerRe: text shape form? Pinmembershabonaa31-Jan-06 8:55 
GeneralNice, but.. PinmemberFZelle17-Jan-06 22:27 
GeneralRe: Nice, but.. Pinmembershabonaa18-Jan-06 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 17 Jan 2006
Article Copyright 2006 by shabonaa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid