Please enable JavaScript to view this site.

KOL/MCK - User Guide

TIcon( unit KOL.pas ) TObj _TObj

TIcon = object( TObj )

Object type to incapsulate icon or cursor image.

 

function NewIcon: PIcon;

Creates new icon object, setting its Size to 32 by default. Created icon is Empty.

 

 

TIcon properties

 

property Size: Integer;

Icon dimension (width and/or height, which are equal to each other always).

 

property Handle: HIcon;

Windows icon object handle.

 

property Empty: Boolean;  

Returns True if icon is Empty.

 

property ShareIcon: Boolean;

True, if icon object is shared and can not be deleted when TIcon object is destroyed (set this flag is to True, if an icon is obtained from another TIcon object, for example).

 

property HotSpot: TPoint;  

Hot spot point - for cursors.

 

 

TIcon methods

 

procedure SetHandleEx( NewHandle: HIcon );

Set Handle without changing Size (Width/Height).

 

procedure Clear;

Clears icon, freeing image and allocated GDI resource (Handle).

 

procedure Draw( DC: HDC; X, Y: Integer );

Draws icon onto given device context. Icon always is drawn transparently using its transparency mask (stored internally in icon object).

 

procedure StretchDraw( DC: HDC; Dest: TRect );

Draws icon onto given device context with stretching it to fit destination rectangle. See also Draw.

 

procedure LoadFromStream( Strm: PStream );

Loads icon from stream. If stream contains several icons (of different dimentions), icon with the most appropriate size is loading.

 

procedure LoadFromFile( const FileName: KOLString );

Load icon from file. If file contains several icons (of different dimensions), icon with the most appropriate size is loading.

 

procedure LoadFromResourceID( Inst: Integer; ResID: Integer; DesiredSize: Integer );

Loads icon from resource. To load system default icon, pass 0 as Inst and one of followin values as ResID:

 

IDI_APPLICATION

Default application icon.

IDI_ASTERISK

Asterisk (used in informative messages).

IDI_EXCLAMATION

Exclamation point (used in warning messages).

IDI_HAND

Hand-shaped icon (used in serious warning messages).

IDI_QUESTION

Question mark (used in prompting messages).

IDI_WINLOGO

Windows logo.

 

It is also possible to load icon from resources of another module, if pass instance handle of loaded module as Inst parameter.

 

procedure LoadFromResourceName( Inst: Integer; ResName: PKOLChar; DesiredSize: Integer );

Loads icon from resource. To load own application resource, pass hInstance as Inst parameter. It is possible to load resource from another module, if pass its instance handle as Inst.

 

procedure LoadFromExecutable( const FileName: KOLString; IconIdx: Integer );

Loads icon from executable (exe or dll file). Always default sized icon is loaded. It is possible also to get know how much icons are contained in executable using gloabl function GetFileIconCount. To obtain icon of another size, try to load given executable and use LoadFromResourceID method.

 

procedure SaveToStream( Strm: PStream );

Saves single icon to stream. To save icons with several different dimensions, use global procedure SaveIcons2Stream.

 

procedure SaveToFile( const FileName: KOLString );

Saves single icon to file. To save icons with several different dimensions, use global procedure SaveIcons2File.

 

function Convert2Bitmap( TranColor: TColor ): HBitmap;

Converts icon to bitmap, returning Windows GDI bitmap resource as a result. It is possible later to assign returned bitmap handle to Handle property of TBitmap object to use features of TBitmap. Pass TranColor to replace transparent area of icon with given color.

 

 

Global Functions

 

procedure SaveIcons2Stream( const Icons: array of PIcon; Strm: PStream );

Saves several icons (of different dimentions) to stream.

 

function SaveIcons2StreamEx( const BmpHandles: array of HBitmap; Strm: PStream ): Boolean;

Saves icons creating it from pairs of bitmaps and their masks. BmpHandles array must contain pairs of bitmap handles, each pair of color bitmap and mask bitmap of the same size.

 

procedure SaveIcons2File( const Icons: array of PIcon; const FileName: KOLString );

Saves several icons (of different dimentions) to file. (Single file with extension .ico can contain several different sized icon images to use later one with the most appropriate size).

 

function GetFileIconCount( const FileName: KOLString ): Integer;

Returns number of icon resources stored in given (executable) file.

 

function LoadImgIcon( RsrcName: PKOLChar; Size: Integer ): HIcon;

Loads icon of specified size from the resource.

 

 

function FileIconSystemIdx( const Path: KOLString ): Integer;

Returns index of the index of the system icon correspondent to the file or directory in system icon image list.

 

function FileIconSysIdxOffline( const Path: KOLString ): Integer;

The same as FileIconSystemIdx, but an icon is calculated for the file as it were offline (it is possible to get an icon for file even if it is not existing, on base of its extension only).

 

function DirIconSysIdxOffline( const Path: KOLString ): Integer;

The same as FileIconSysIdxOffline, but for a folder rather then for a file.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC