Transparency

  • 14 years ago

    In VB 6 I used to be able to add a picture to a form and then I would put a transparent label on top and adjust it to cover a certain part of the image, then I would have something happen during that Label's click event if a user clicked on that particular area. Basically, i created an image map.

    I have use for this again, but I have come to realize that VB.NET's controls are solid or at least so I have read on other sites when searching for answers to why I couldn't make the label control for instance transparent anymore.

    One suggestion I read was setting the Transparency Key to the form and the control I wanted transparent to the same color. I tested this with the Label control and it does indeed work, but it works a little bit too good. It makes a hole right through the form the size of the control I made transparent with the form and through that hole I can see anything, be it the VB code window, a portion of my desktop image, whatever just happens to be behind the form as it is running.

     

    So my question is, are there any other tips/tricks I can use to allow a user to click on different ares of an image on my form? thanks.

  • 14 years ago

    Here is one way you could accomplish this.  You'll have to make it transparent during run-time though.  At least I think it must be done during run-time.  Just run the code during form load or whenever is appropriate and you'll be all set.

            'Set the parent control
            Label1.Parent = PictureBox1
            'Reposition the label so it remains in the same relative location
            Label1.Location = Label1.Location - PictureBox1.Location
            'Give it a transparent background
            Label1.BackColor = Color.Transparent

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”