CImageList::Add
Call this function to add one or more images or an icon to an image list.
int Add(
CBitmap* pbmImage,
CBitmap* pbmMask
);
int Add(
CBitmap* pbmImage,
COLORREF crMask
);
int Add(
HICON hIcon
);
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.
Return Value
Zero-based index of the first new image if successful; otherwise – 1.
Remarks
You are responsible for releasing the icon handle when you are done with it.
Example
// Add my icons.
m_myImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_myImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
// Add my bitmap, make all black pixels transparent.
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
m_myImageList.Add(&bm, RGB(0, 0, 0));
Requirements
Header: afxcmn.h
See Also
Reference
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
June 2010 |
Added note about releasing the handle. |
Customer feedback. |