Create an Irregular shaped Windows Form with VB.NET
My Active Skin Irregular Form page is
one of the most visited pages on this web site. Here is the VB.NET equivalent!
This code lets you create an Irregular form from
any bitmap image. Irregular forms are forms that do not have the standard
rectangular shape. The methodology is similar to that on my
Active Skin page. A bitmap is scanned and a Windows
Region is created then applied to the form.
The following image is a form in the shape of SpongeBob. If you click on him you
will click the form. However, if you click on his eyes you will be clicking the
underlying window (Visual Studio editor in this image).
All code to create irregular forms is encapsulated in a class module you can add
to your project. You can specify any bitmap and which color to use as the
transparent color. If no transparent color is specified the color of the
top-left most pixel is used.
In this sample I scan a bitmap and do all the work programatically. You can also
do it using the following few lines of C# code.
System.Drawing.Bitmap Img = new System.Drawing.Bitmap(@"C:\...\SpongeBob.bmp");
// The color at Pixel(1,1) is rendered as transparent for the complete background.
this.BackgroundImage = Img;
this.TransparencyKey = Img.GetPixel(1,1);