WinForms FAQ - Paths and Regions

What is a GraphicsPath

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
Is there a imagemap like control in Windows Forms

There isn’t one out of the box. But check out this codeproject article for a control that provides this functionality.

ImageMap control on Codeproject

Permalink
How can I create non-rectangular windows

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