Icon#

Qualified name: delphivcl.Icon

class Icon#

Bases: Graphic

TIcon is an encapsulation of a Windows icon. Use TIcon to represent one of the icons in an image list. Assign an icon to objects that have an Icon property, such as TForm or TPicture. Icon objects represent the value loaded from a Windows icon file (.ICO file). Draw an icon on a canvas, using the Draw method of the TCanvas object. Icons do not stretch, so do not use StretchDraw (TCanvas) with an icon.

Note: TIcon can be used to display the value of a multi-resolution (>16 color) icon. However, it can not support the creation of multi-resolution icons, nor the resizing of the image after it is loaded from a file or stream.

Methods

Assign

Copies an icon image from another TIcon object.

AssignTo

Copies an icon image to a TBitmap graphical object.

CanLoadFromStream

Vcl.Graphics.TIcon.CanLoadFromStream inherits from Vcl.Graphics.TGraphic.CanLoadFromStream.

Create

Creates an instance of TIcon.

Destroy

Destroys an instance of TIcon.

HandleAllocated

Indicates whether the TIcon object has acquired a handle to the underlying GDI object.

LoadFromClipboardFormat

Prevents applications from loading icons from the clipboard.

LoadFromResourceID

Embarcadero Technologies does not currently have any additional information.

LoadFromResourceName

Loads an icon resource into the icon object.

LoadFromStream

Loads the icon from a stream.

ReleaseHandle

Releases the Windows GDI object represented by the icon.

SaveToClipboardFormat

Prevents applications from saving icons to the clipboard.

SaveToStream

Saves the icon to a stream.

SetSize

Specifies the size of the icon.

Attributes

ClassName

Returns the TObject.ClassName

Empty

Indicates whether the graphics object contains a graphic.

Handle

Provides access to the Windows GDI icon handle.

Height

Specifies the vertical size of the graphic in pixels.

Modified

Indicates whether the graphics object has been changed or edited.

OnChange

<Delphi property OnChange of type TGraphic at 21141225010>

OnProgress

<Delphi property OnProgress of type TGraphic at 211412250E0>

Palette

Indicates the color palette of the graphical image.

PaletteModified

Indicates whether the palette has changed.

ScaledDrawer

Returns the reference to the scaled drawer.

SupportsPartialTransparency

Indicate whether graphic supports partial transparency or an alpha channel.

Transparent

Indicates whether the image covers its rectangular area.

Width

Determines the maximum width of the graphics object in pixels.

Assign(Source: Persistent)#

Copies an icon image from another TIcon object. Call Assign to copy another icon object. Assign copies the icon image from the Source parameter if it is another TIcon object. Otherwise, Assign calls the inherited method, which copies the icon image from any source object that specifies how to copy to a TIcon in its AssignTo method.

AssignTo(Dest: Persistent)#

Copies an icon image to a TBitmap graphical object. Call AssignTo to copy an icon to a TBitmap object. AssignTo copies the icon image to the Dest parameter if it is a TBitmap object. Otherwise, AssignTo fails. The preferred way to copy an icon image to a bitmap is to use the Assign method of the TBitmap class, passing the icon object as the Source parameter.

Note: The bitmap resulted after a call to AssignTo always has alpha channel (transparency) information and a 32-bit color depth.

CanLoadFromStream(Stream: Stream) Boolean#

Vcl.Graphics.TIcon.CanLoadFromStream inherits from Vcl.Graphics.TGraphic.CanLoadFromStream. All content below this line refers to Vcl.Graphics.TGraphic.CanLoadFromStream. CanLoadFromStream returns True when a specified stream contains a streamed image of a specific TGraphic subclass. The method uses current stream position, it does not change current stream position.

Create()#

Creates an instance of TIcon. Call Create to create an empty icon object. Once an image has been read into the icon from a file or stream, or by assigning another icon object, the icon can be drawn on a canvas or added to an image list. Do not create an icon object for setting the icon property of a form or picture. These objects create a TIcon object in their own constructors. Instead, use the LoadFromFile, LoadFromStream, or LoadFromClipboardFormat method on the TIcon object that you can obtain by reading the Icon property.

Destroy()#

Destroys an instance of TIcon. Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TIcon reference is not nil, and only then calls Destroy.

Handle#

Provides access to the Windows GDI icon handle. Use Handle to specify the icon when using a Windows API function that requires the handle of an icon object. The Handle property is nil (Delphi) or NULL (C++) if the icon has not been loaded. Call the ReleaseHandle method before changing the icon image by setting the Handle property. The icon image can also be loaded by assigning another icon object or using the LoadFromClipboardFormat, LoadFromFile, or LoadFromStream method.

HandleAllocated()#

Indicates whether the TIcon object has acquired a handle to the underlying GDI object. Use HandleAllocated to determine whether the Handle property is set to an HICON value. HandleAllocated indicates whether the underlying GDI object has already been created. Use HandleAllocated rather than reading the Handle property. When an application reads the Handle property, it automatically creates an icon and returns its handle if the underlying GDI object does not already exist.

LoadFromClipboardFormat(AFormat: Word, AData: NativeUInt, APalette: HPALETE)#

Prevents applications from loading icons from the clipboard. LoadFromClipboardFormat is overridden in TIcon because the clipboard format is not supported.

LoadFromResourceID(Instance: NativeUInt, ResID: Integer)#

Embarcadero Technologies does not currently have any additional information.

LoadFromResourceName(Instance: NativeUInt, ResName: string)#

Loads an icon resource into the icon object. LoadFromResourceName loads the specified icon resource from a module’s executable file. Instance is the handle of the module that contains the resource. ResName is the name of the resource to load.

LoadFromStream(Stream: Stream)#

Loads the icon from a stream. Use LoadFromStream to read the icon image from a stream. Set the Stream parameter to a stream object that provides access to the memory image of the icon. To load the icon from a .ico file, use the LoadFromFile method. To load the icon from the Clipboard, use the LoadFromClipboardFormat method.

ReleaseHandle()#

Releases the Windows GDI object represented by the icon. Call ReleaseHandle to release the resources used to represent the icon. ReleaseHandle sets the Handle property to nil (Delphi) or NULL (C++). ReleaseHandle informs the TIcon instance that it is no longer responsible for destroying the icon handle.

SaveToClipboardFormat(Format: Word, Data: NativeUInt, APalette: HPALETE)#

Prevents applications from saving icons to the clipboard. SaveToClipboardFormat is overridden in TIcon because the format is not supported for the Clipboard.

SaveToStream(Stream: Stream)#

Saves the icon to a stream. Use SaveToStream to write the icon image to a stream. Specify the Stream parameter as the stream object that receives the memory image of the icon. To write the icon to a .ico file, use the SaveToFile method. To write the icon to the Clipboard, use the SaveToClipboardFormat method.

SetSize(AWidth: Integer, AHeight: Integer)#

Specifies the size of the icon. Use the SetSize method to set both the height and width of the icon. This results in better performance than setting the height and width separately.