Share via


MaskColor for Visual Basic 6.0 Users

The MaskColor property in Visual Basic 6.0 has no direct equivalent in Visual Basic 2008, however you can use graphics methods to achieve the same effect.

Conceptual Differences

In Visual Basic 6.0, the MaskColor property of a CheckBox, CommandButton, or OptionButton control was used to define a color that would become transparent, allowing a background image to show. To use this property, the Style property had to be set to Graphical, the UseMaskColor property had to be set to True, and a bitmap had to be assigned to the Picture property.

In Visual Basic 2008, there is no direct equivalent for the MaskColor property. You can, however, set transparency on a control using the MakeTransparent method of a Bitmap object.

Code Changes for MaskColor

The following code shows the differences in coding techniques between Visual Basic 6.0 and Visual Basic 2008.

' Visual Basic 6.0

' Assumes a picture has been assigned to the Picture property

' and that the Style property has been set to Graphical.

Command1.UseMaskColor = True

Command1.MaskColor = vbWhite

' Visual Basic' Assumes a picture has been assigned to the BackgroundImage property.Dim g AsNew System.Drawing.Bitmap(Button1.BackgroundImage)
g.MakeTransparent(System.Drawing.Color.White)
Button1.BackgroundImage = g

Upgrade Notes

When upgrading an application from Visual Basic 6.0 to Visual Basic 2008, the upgrade wizard does not upgrade code that uses the MaskColor property. Upgrade warnings will be inserted into your code. You will need to modify the code before running the application.

See Also

Concepts

CheckBox Control for Visual Basic 6.0 Users

CommandButton Control for Visual Basic 6.0 Users

OptionButton Control for Visual Basic 6.0 Users

Reference

Color Handling for Visual Basic 6.0 Users

MakeTransparent