MaskColor, UseMaskColor Properties (ImageList)

Purpose

Determines how and if a masked bitmap is created for the next image of an ImageList control.

Syntax

ImageList.MaskColor [ = rgb ]

ImageList.UseMaskColor [ = Boolean ]

rgb:iexp

Description

When UseMaskColor is set, new images have their mask added to the list as well. Of course, the ImageList control must be created using the correct ColorFormat value to have masked images in the first place.

With MaskColor you specify a color to be combined with the image bitmap to generate the masks. When you do this, each pixel of the specified color in the image bitmap is changed to black, and the corresponding bit in the mask is set to one. This results in transparency for any pixel in the image that matches the specified color when the image is drawn. That is to say, transparency is only obtained in a ListImage.Draw or ImageList.Overlay operation.

Example

OpenW 1, 30, 30, 300, 300 : Win_1.AutoRedraw = 1

Cls colBtnFace

Ocx ImageList iml : .ImageWidth = 32 : .ImageHeight = 32

iml.ColorFormat = 1

iml.MaskColor = $0c0c0c

iml.UseMaskColor = True

iml.ListImages.Add , "new", CreatePicture(LoadIcon(Null, IDI_WARNING), False)

iml.ListImages(1).Draw Me.hDC, 0, 30, 0

iml.ListImages.Item(1).Draw Me.hDC, 50, 30, 1

iml.ListImage(1).Draw Me.hDC, 100, 30, 2

Dim lim As ListImage

Set lim = iml.ListImage(1)

lim.Draw Me.hDC, 150, 30, 3

Remarks

The UseMaskColor and MaskColor properties can only be modified before a single image is added to the image list, it is not a general setting.

The UseMaskColor and MaskColor properties have no proper function when the ImageList is used as an image repository for ToolBar buttons. The ToolBar control simply draws the non-masked images on the button surface.

See Also

ImageList, ListImage

{Created by Sjouke Hamstra; Last updated: 13/10/2014 by James Gaite}