How do I create windows with irregular shapes using WinForms and C#?
+5
A:
Have a look at this question.
http://stackoverflow.com/questions/176720/irregular-shaped-windows-form-c
Nifle
2009-08-25 07:57:57
thats just virtual, transparent images as backgrounds.... no i mean actually irregular windows
Junaid Saeed
2009-08-25 08:00:13
+5
A:
There are a few different ways to achieve this. One is use use TransparencyKey
(as in the post pointed out by Nifle). Another one is to assign a Region
object to the Region
property of the form:
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddPolygon(new[]
{
new Point(20, 20),
new Point(40, 10),
new Point(180, 70),
new Point(160, 260),
new Point(80, 140)
});
path.AddEllipse(40, 40, 300, 300);
this.Region = new Region(path);
Note that the coordinates refer to the window, not the client area. Also note how overlapping figures in the GraphicsPath
object "invert" each other by default (this can be prevented by setting path.FillMode = FillMode.Winding
).
Fredrik Mörk
2009-08-25 08:00:07