Search Amazon:

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.

    
    InitializeComponent();
    
    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.
    Img.MakeTransparent(Img.GetPixel(1,1));
    this.BackgroundImage = Img;   
    this.TransparencyKey = Img.GetPixel(1,1);
    

Create Irregular forms with VB.NET
Download the code

Sign In
  User Id 
  Password 


Submit Your Own Code and Articles




About TheScarms
About TheScarms

Ask me your programming questions

I read every email and answer all I can.

User Feedback: Be the first to add a comment! Items to Show:     

     
You must log in to post feedback.
Comment:    
 

If you use this code, please mention "www.TheScarms.com"

Email this page


TheScarms AppSentinel lets you securely copy protect and create evaluation versions of your software

TheScarms(tm) AppSentinel lets you quickly and easily create evaluation versions of your software and stop unauthorized copying and unregistered use of your programs!

Get your free
trial copy today!


      The World's Number 1 Web Host

© Copyright 2008 TheScarms