ImageList_ReplaceIcon function (commctrl.h)

Replaces an image with an icon or cursor.

Syntax

int ImageList_ReplaceIcon(
  HIMAGELIST himl,
  int        i,
  HICON      hicon
);

Parameters

himl

Type: HIMAGELIST

A handle to the image list.

i

Type: int

The index of the image to replace. If i is -1, the function appends the image to the end of the list.

hicon

Type: HICON

The handle to the icon or cursor that contains the bitmap and mask for the new image.

Return value

Type: int

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

Remarks

Because the system does not save hicon, you can destroy it after the function returns if the icon or cursor was created by the CreateIcon function. You do not need to destroy hicon if it was loaded by the LoadIcon function; the system automatically frees an icon resource when it is no longer needed.

Requirements

   
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)