Image List Control

Setting the Mask Property

When using the ImageList control, there are two types of images you are most likely to be adding: Icons and Bitmaps. All icons have a pre-defined colour, set when it is created, which will be shown as transparent. Bitmaps, however, do not. Because of this, when you add Bitmaps to the ImageList control, you need to specify a colour to show as transparent. This is normally the background colour of the Bitmap. To do this, you need to set the Mask property. All the toolbar bitmaps provided with Visual Basic use the colour &H00C0C0C0&. This doesn't make any sense, because it is a Hexadecimal code, but it doesn't matter... Therefore, enter &H00C0C0C0& into the Mask colour property, and press enter. Also, you need to make sure that the UseMaskColor property is set to true. In the same way, if you don't want to set a Mask colour, you can set this to False.

If you are already using the images in a toolbar, many of you will not notice any difference from when you have set the Mask property, and when you have not. However, try this experiment:

Set the ImageList's UseMaskColor property to False. Then, show the display properties dialog (right click on the desktop and click properties). Click the Appearance tab. Before we change anything, save the current settings by clicking Save As, and type a name. Now, select 3D objects from the Item drop down, and change the top colour to something else. Click Apply. Now, go back to Visual Basic, and run your program. Take a look at the toolbar, and you will see something like this:

The reason these grey boxes are appearing is because the background colour set to transparent. Change the UseMaskColor property to True, and then take a look.

Occasionally, you will find that this doesn't work. This is because the MaskColor property is not the exact colour that is used as the background. Finding the exact colour is sometimes difficult - even taking a screen shot and using Paint to work out what colour it is does not always work. If you are having problems, try the other Hex codes listed below. If that doesn't work, email me and I will try to help!

Hex codes to try:

&H00C0C0C0&
&H00BFBFBF&
&H00BDBDBD&

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

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.

“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” - Bill Gates