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

# TCustomIcon.GetIndex

GetIndex - returns the Index value of the Icon with specified format and size (.icn files can contain several versions of image).

## Declaration

Source position: graphics.pp line 1622

`protected function TCustomIcon.GetIndex(`
`AFormat: TPixelFormat;`
`AHeight: Word;`
`AWidth: Word`
`):Integer;`

## Arguments

`AFormat` |  | Color depth for the requested icon image.
`AHeight` |  | Height for the requested icon image.
`AWidth` |  | Width for the requested icon image.

## Function result

Ordinal position for the image with the requested attributes, or -1 when not found.

## Description

Gets the ordinal position in the internal image list for the icon with the specified pixel format, height, and width. The return value is -1 if an image using all of the requested values was not found in the list.

Assign the return value to the Current property to use it as the selected image for the icon.

Use GetBestIndexForSize to find the position of the image which matches most closely the specified height and width.

## See also

TCustomIcon.Current |  | Ordinal position for the current image displayed for the icon.
TCustomIcon.GetBestIndexForSize |  | Gets the ordinal position for the image closest to the requested size.
TSharedIcon.GetIndex |  | Gets the Index of an image with specified pixel format, height and width.
TSharedIcon.Images |  | Provides indexed access to the images available in the Icon.