Click here to Skip to main content
11,481,850 members (63,858 online)
Click here to Skip to main content

Irregular Shaped Form

, 17 Jan 2006 53.4K 3K 40
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 Pin
manoj kumar choubey5-Apr-12 0:49
membermanoj kumar choubey5-Apr-12 0:49 
GeneralTransparent Form and windows media player Pin
divyesh143220-Jun-08 22:06
memberdivyesh143220-Jun-08 22:06 
General[Message Deleted] Pin
myventsi28-Nov-07 10:01
membermyventsi28-Nov-07 10:01 
GeneralRe: Where can i find DrawPath ??? Pin
shabonaa28-Nov-07 12:02
membershabonaa28-Nov-07 12:02 
QuestionJust a quick question ... Pin
b0ksah12-Feb-07 2:02
memberb0ksah12-Feb-07 2:02 
AnswerRe: Just a quick question ... Pin
shabonaa13-Feb-07 22:15
membershabonaa13-Feb-07 22:15 
Questiontext shape form? Pin
Jaamsadams30-Jan-06 16:20
memberJaamsadams30-Jan-06 16:20 
AnswerRe: text shape form? Pin
shabonaa31-Jan-06 9:55
membershabonaa31-Jan-06 9:55 
GeneralNice, but.. Pin
FZelle17-Jan-06 23:27
memberFZelle17-Jan-06 23:27 
GeneralRe: Nice, but.. Pin
shabonaa18-Jan-06 10:26
membershabonaa18-Jan-06 10: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 | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 17 Jan 2006
Article Copyright 2006 by shabonaa
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid