CImageList::Add

int Add( CBitmap* pbmImage, CBitmap* pbmMask );

int Add( CBitmap* pbmImage, COLORREF crMask );

int Add( HICON hIcon );

Return Value

Zero-based index of the first new image if successful; otherwise  – 1.

Parameters

pbmImage

Pointer to the bitmap containing the image or images. The number of images is inferred from the width of the bitmap.

pbmMask

Pointer to the bitmap containing the mask. If no mask is used with the image list, this parameter is ignored.

crMask

Color used to generate the mask. Each pixel of this color in the given bitmap is changed to black and the corresponding bit in the mask is set to one.

hIcon

Handle of the icon that contains the bitmap and mask for the new image.

Remarks

Call this function to add one or more images or an icon to an image list.

Example

// The pointer to my image list.
extern CImageList* pmyImageList;

// Add my icons.
pmyImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON1));
pmyImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON2));

// Add my bitmap, make all black pixels transparent.
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
pmyImageList->Add(&bm, RGB(0, 0, 0));

CImageList OverviewClass MembersHierarchy Chart

See Also   CImageList::Remove, CImageList::Replace, COLORREF