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

# TCustomImageList.InsertIcon

Inserts an Icon into each of the resolutions for the image list.

## Declaration

Source position: imglist.pp line 382

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

## Arguments

`AIndex` |  | Position in the image list where the icon is inserted.
`AIcon` |  | The Icon to insert into the image list.

## Description

InsertIcon is a procedure used to insert an icon at the specified position in each of the resolutions for the image list.

AIndex contains the ordinal position in the image list where the icon is stored.

AIcon is the TCustomIcon instance stored in the method. AIcon allows multiple icon sizes to be available in the class instance. No actions are performed in the method when AIcon is unassigned (contains Nil). To ensure that the icon sizes in AIcon are in ascending size order, a temporary TIcon instance is created and its Sort method is called.

InsertIcon uses the Resolutions enumerator to visit each of the image resolutions used in the image list. GetBestIconIndexForSize is called for each image resolution to get the icon size for the width in the resolution. ScaleImage is called to resize the icon bitmap and mask (when present) to the height and width required for the image resolution. The InternalInsert method in the image resolution is called to store the scaled raw image data for the icon at the position in AIndex.

## 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.
TCustomImageListResolution |  | Implements an image resolution (or size) used in TCustomImageList.
TCustomIcon |  | TCustomIcon - base class for TIcon.