VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[PRB] Mouse event aren’t received by transparent Image and Label controls

In VB6, Image controls whose Picture property is Nothing and Label controls with null caption and BackStyle set to 0-Transparent have transparent background: you can see "through" them even if the control receive mouse events. This technique is often used by VB6 developers to create clickable "hot spots" over a form or a background image.

The problem in converting these controls is that these controls aren’t transparent at all after the migration to VB2005. You actually need to make them invisible only by setting their Visible property to False, but this remedy prevents the controls from receiving mouse events. VB Migration Partner handles this case by making the control invisible and manually forwarding mouse events to them.

You usually don’t need to do anything to have the VB2005 code work correctly, except in the following scenario: you have a form with an Image control on it that contains a background image and then many transparent Image or Label controls that work as hot spots. In this case, in fact, by default VB Migration Partner sends the mouse event to the background Image control and fails to forward it to the transparent Image controls.

You can solve this problem in two ways: by replacing the background Image control with a PictureBox or by setting the background Image control’s IsBackgroundControl property. Setting this special property – exposed by the VB6Image and VB6Label controls – to True forces VB Migration Partner to search other transparent controls in the same container – the form, usually – and correctly forwards all mouse events. The easiest way to set this property is by means of a WriteProperty pragma:

        '## imgBack.WriteProperty IsBackgroundControl, True
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers