ImageList_AddMasked function (commctrl.h)

Adds an image or images to an image list, generating a mask from the specified bitmap.

Syntax

int ImageList_AddMasked(
  HIMAGELIST himl,
  HBITMAP    hbmImage,
  COLORREF   crMask
);

Parameters

himl

Type: HIMAGELIST

A handle to the image list.

hbmImage

Type: HBITMAP

A handle to the bitmap that contains one or more images. The number of images is inferred from the width of the bitmap.

crMask

Type: COLORREF

The color used to generate the mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to 1. If this parameter is CLR_DEFAULT, then the color of the pixel at (0,0) is used as the mask.

Return value

Type: int

Returns the index of the first new image if successful, or -1 otherwise.

Remarks

The ImageList_AddMasked function copies the bitmap to an internal data structure. Bitmaps with color depth greater than 8bpp are not supported. Be sure to use the DeleteObject function to delete hbmImage after the function returns.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header commctrl.h
Library Comctl32.lib
DLL Comctl32.dll
API set ext-ms-win-shell-comctl32-init-l1-1-1 (introduced in Windows 10, version 10.0.14393)