Form.Region : Form « System.Windows.Forms « C# / C Sharp by API






Form.Region

    
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public class IrregularForm : Form
{
    public IrregularForm()
    {
        this.cmdClose = new System.Windows.Forms.Button();
        this.SuspendLayout();

        this.cmdClose.Location = new System.Drawing.Point(94, 231);
        this.cmdClose.Size = new System.Drawing.Size(75, 23);
        this.cmdClose.Text = "Close";
        this.cmdClose.UseVisualStyleBackColor = true;
        this.cmdClose.Click += new System.EventHandler(this.cmdClose_Click);

        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(295, 270);
        this.Controls.Add(this.cmdClose);
        this.Text = "Irregular Form";
        this.Load += new System.EventHandler(this.IrregularForm_Load);
        this.ResumeLayout(false);

    }

    private void IrregularForm_Load(object sender, EventArgs e)
    {
        GraphicsPath path = new GraphicsPath();

        Point[] pointsA = new Point[]{new Point(0, 0),new Point(40, 60), new Point(this.Width - 100, 10)};
        path.AddCurve(pointsA);

        Point[] pointsB = new Point[]{
                new Point(this.Width - 40, this.Height - 60), 
                new Point(this.Width, this.Height),
                new Point(10, this.Height)
            };
        path.AddCurve(pointsB);

        path.CloseAllFigures();

        this.Region = new Region(path);
    }

    private void cmdClose_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private System.Windows.Forms.Button cmdClose;
    
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new IrregularForm());
    }
    
}

   
    
    
    
  








Related examples in the same category

1.new Form()
2.extends Form
3.Form.AcceptButton
4.Form.ActiveForm.Location
5.Form.Activated
6.Form.AddOwnedForm
7.Form.AutoScaleBaseSize
8.Form.AutoScroll
9.Form.AutoScrollMinSize
10.Form.BackColor
11.Form.CancelButton
12.Form.CenterToScreen()
13.Form.ClientRectangle
14.Form.ClientSize
15.Form.Closed
16.Form.Closing
17.Form.ContextMenu
18.Form.ControlBox
19.Form.Controls
20.Form.Cursor
21.Form.DesktopBounds
22.Form.DialogResult
23.Form.DisplayRectangle
24.Form.Dispose
25.Form.FormBorderStyle
26.Form.ForeColor
27.Form.GotFocus
28.Form.Height
29.Form.Hide()
30.Form.Invalidate
31.Form.IsMdiContainer
32.Form.KeyPress
33.Form.KeyPreview
34.Form.KeyUp
35.Form.Load
36.Form.Location
37.Form.MaximizeBox
38.Form.MaximumSize
39.Form.MdiParent
40.Form.MenuComplete
41.Form.Menu
42.Form.MinimizeBox
43.Form.MinimumSize
44.Form.MouseDown
45.Form.MouseLeave(All other events)
46.Form.MouseUp
47.Form.OnDragDrop
48.Form.OnDragOver
49.Form.OnInputLanguageChanged
50.Form.OnKeyDown
51.Form.OnKeyPress
52.Form.OnMouseEnter
53.Form.OnMouseHover
54.Form.OnMouseLeave
55.Form.OnMouseMove
56.Form.OnMouseWheel
57.Form.OnPaint(PaintEventArgs e)
58.Form.OnResize
59.Form.Opacity
60.Form.Paint
61.Form.Resize
62.Form.ResizeRedraw
63.Form.SetStyle
64.Form.ShowInTaskbar
65.Form.Size
66.Form.Show
67.Form.StartPosition
68.Form.SuspendLayout
69.Form.Text
70.Form.Top
71.Form.TransparencyKey
72.Form.Visible
73.Form.Width
74.Form.WindowState