Setting the control region
Everybody who used Windows XP has very probably noticed that buttons have rounded corners. The graphic shape of the button looks like this:
So, we'll create such a region (the interior of a graphics shape) for our button.
int X = this.Width;
int Y = this.Height;
Point[] points = { new Point(1, 0),
new Point(X-1, 0),
new Point(X-1, 1),
new Point(X, 1),
new Point(X, Y-1),
new Point(X-1, Y-1),
new Point(X-1, Y),
new Point(1, Y),
new Point(1, Y-1),
new Point(0, Y-1),
new Point(0, 1),
new Point(1, 1)}
GraphicsPath path = new GraphicsPath();
path.AddLines(points);
this.Region = new Region(path);
[DllImport("gdi32.Dll")]
public static extern int CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);