Live Chat Icon For mobile
Live Chat Icon

WinForms FAQ - Paths and Regions

Find answers for the most frequently asked questions
Expand All Collapse All

The GraphicsPath class represents a series of connected lines and curves.

Michael Gold uses this class to draw the hands for his Virtual Clock sample found on C# Corner.

Permalink

Check out this Microsoft KB article, Shaped Windows Forms and Controls in Visual Studio .NET

There are 2 ways to create non-rectangular windows:

1) The Control.Region property (Form inherits this of course):

[CS]
	GraphicsPath gp = new GraphicsPath();
	gp.AddEllipse(0,0,100,100);
	gp.AddRectangle(50,50,100,100);
	this.Region = new Region(gp);

[VB.NET]
	Dim gp As New GraphicsPath()
	gp.AddEllipse(0, 0, 100, 100)
	gp.AddRectangle(50, 50, 100, 100)
	Me.Region = New [Region](gp)

2) Use the Form.TransparencyKey property. This tells the form not to paint any pixels that match the color of the TransparencyKey. So you can make your fancy skin bitmap, then set the TransparencyKey to be, say Color.Red,
then all the pixels that are RGB(255,0,0) will be transparent.

(from sburke_online@microsoft..nospam..com on microsoft.public.dotnet.framework.windowsforms)

Permalink

Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.