IImageList::Replace method (commoncontrols.h)

Replaces an image in an image list with a new image.

Syntax

HRESULT Replace(
  [in]           int     i,
  [in]           HBITMAP hbmImage,
  [in, optional] HBITMAP hbmMask
);

Parameters

[in] i

Type: int

A value of type int that contains the index of the image to replace.

[in] hbmImage

Type: HBITMAP

A handle to the bitmap that contains the image.

[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.

Return value

Type: HRESULT

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

Remarks

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

To use IImageList::Replace, 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)