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

# TCustomIcon.UnshareImage

Unshares the shared image when the content in the icon is changed.

## Declaration

Source position: graphics.pp line 1644

`protected procedure TCustomIcon.UnshareImage(`
`CopyContent: Boolean`
`); override;`

## Arguments

`CopyContent` |  | True if existing image content is copied in the method.

## Description

UnshareImage is an overridden procedure used to stop sharing the image(s) for the icon. UnshareImage implements the abstract virtual method defined in the ancestor class.

No actions are performed in the method when the RefCount for the internal TSharedIcon instance is less than 1.

When sharing is stopped, the internal TSharedIcon instance in the class is re-created.

CopyContent indicates whether existing content from icon images is copied into the new image list. When set to True, TIconImage instances are re-created for each of the icon images and their existing content is copied. When set to False, image data for the icon is empty.

UnshareImage calls FreeCanvasContext to discard the device context used in the Canvas.

UnshareImage calls the Release method for the old TSharedIcon instance.

UnshareImage is called from methods which alter the handle or image content for the icon, including:

- SetHandle
- Add
- Assign
- AssignImage
- Delete

## See also

TRasterImage.UnshareImage |  | Unshares a shared image when its handle is changed or the save stream is freed.