Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 75,864 times

Contents

Related Categories

Image List Control - Setting the Mask Property

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&

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Visual Basic

    Posted by Anuradha on 23 Jul 2002

    I am new to VB and I am sort working thru exercises in a book

    I came across one that has me a bit stuck
    It basically says to create a form with two ImageList Controls ,add the images to one con...

  • Posted by battleangel444 on 18 Apr 2002

    hey i hope this helps i was tryin to do the same thing you were tryin to do and i stuble upon your topic, try using this

    ImageList1.ListImages.Add ImageList1.ListImages.count + 1, , LoadPicture(txt...

  • dynamically populating imagelist

    Posted by theoskii on 09 Apr 2002



    I am very new to VB and I am sort working thru exercises in a book

    I came across one that has me a bit stuck
    It basically says to create a form with two ImageList Controls populate the first ...