IImageList::Add method (commoncontrols.h)

Adds an image or images to an image list.

Syntax

HRESULT Add(
  [in]           HBITMAP hbmImage,
  [in, optional] HBITMAP hbmMask,
  [out]          int     *pi
);

Parameters

[in] hbmImage

Type: HBITMAP

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

[in, optional] hbmMask

Type: HBITMAP

A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored.

[out] pi

Type: int*

When this method returns, contains a pointer to the index of the first new image. If the method fails to successfully add the new image, this value is -1.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

IImageList::Add copies the bitmap to an internal data structure. You must use the DeleteObject function to delete hbmImage and hbmMask after the method returns.

To use IImageList::Add, specify Comctl32.dll version 6 in the manifest. For more information on manifests, see Enabling Visual Styles.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header commoncontrols.h
DLL Comctl32.dll (version 6.0 or later)