[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'ImgList' (#lcl)

# TCustomImageList.ReplaceIcon

Replaces the icon at the specified position in all resolutions for the image list.

## Declaration

Source position: imglist.pp line 390

`public procedure TCustomImageList.ReplaceIcon(`
`AIndex: Integer;`
`AIcon: TCustomIcon`
`);`

## Arguments

`AIndex` |  | Ordinal position for the icon replaced in the method.
`AIcon` |  | Icon stored in the method.

## Description

ReplaceIcon is a procedure used to replace the icon stored at the position specified in AIndex in all resolutions for the image list.

AIcon is a TCustomIcon type that contains the graphic image stored in the method. No actions are performed in the method when AIcon has not been assigned (contains Nil).

Icons can contain multiple sizes, and must be in ascending size order to ensure they are applied correctly to image resolutions. ReplaceIcon create a temporary TIcon instance that is used to sort the icons prior to updating the resolutions in the image list.

ReplaceIcon uses the Resolutions enumerator to update each of the image resolutions used in the image list. The GetBestIconIndexForSize method is called to determine the icon size used for each image resolution. The ScaleImage method is called to resize the icon to the width required for each image resolution. If the icon is Masked (has transparent areas), the handle for the bitmap mask is included in the image scaling process. The InternalReplace method in the image resolution is called to store the scaled 32-bit RGBA raw image data.

## See also

TCustomImageList.Resolutions |  | Provides access to the image resolutions (or sizes) used in the image lists.
TCustomImageList.ScaleImage |  | Scales an image and its optional mask to the specified target size.
TCustomImageListResolutions |  | Provides multiple image resolutions in TCustomImageList.