Please enable JavaScript to view this site.

KOL/MCK - User Guide

Pictogram - TIcon

 

Another no less important graphic object is a pictogram (in computer slang - "icon"). Icons in Windows applications are used as icons to identify windows, to distinguish between different buttons on toolbars, and for an immeasurable number of purposes. You can also work with icons through API functions, but in many cases it is convenient to use the TIcon object for this. Constructor:

 

NewIcon - creates an empty TIcon object and returns a pointer to it of the PIcon type;

 

Basic methods and properties of the icon object:

 

Handle - GDI handle to the icon. For a non-empty object, the icon is always not 0. To assign a descriptor of type hIcon or hCursor to an object, it must be assigned to this property;

ShareIcon - determines whether the descriptor is "shared": the shared resource of the icon is not considered to belong to the object, and is not destroyed when the object is destroyed;

Empty - checks that the icon is empty (that is, it is not loaded into the object, and the descriptor is 0);

Clear - clears the object (makes it empty), while if there was a descriptor and it was not shared (ShareIcon), then the descriptor is destroyed, freeing the corresponding GDI resource in the system;

Size - for square icons, shows their size (height and width).

Before loading an icon from external sources (file, resource), this value can be assigned a nonzero value so that when loading an icon that has several image options, the image of the specified size is loaded (by default, the 32x32 icon is always loaded first, and secondly - as close as possible to her in size);

Width - the width of the icon (in order for the width and height to differ, the ICON_DIFF_WH conditional compilation symbol should be included in the project option);

Height - the height of the pictogram (the remark about the symbol of conditional compilation is also true for the height);

HotSpot - the coordinates of the point, which is used to store the "touch point" for cursors (hCursor can also be stored and managed by the TIcon object, since in fact they are no different);

Draw(DC, X, Y) - Draws an icon image on the specified DC context. Drawing a transparent pictogram is always done in a "transparent" manner; Areas corresponding to transparent areas on the target canvas are not affected.

StretchDraw(DC, R) - draws an icon with scaling, fitting it into the specified rectangle;

LoadFromFile(s) - loads an icon from a file;

LoadFromStream(strm) - loads an icon from a data stream;

SaveToFile(s) - saves the icon in the specified file;

SaveToStream(strm) - saves the icon in the data stream;

LoadFromResourceID(inst, resID, sz) - loads an icon from a resource by a numeric resource identifier;

LoadFromResourceName(inst, resName, sz) - loads an icon from a resource by resource name;

LoadFromExecutable(s, i) - loads an icon from the specified executable file (.exe, .dll, etc.), according to the resource number of icons in this file (the global function GetFileIconCount (s) returns the number of resources of icons in the specified executable file);

ConvertToBitmap - creates an hBitmap image based on the icon and returns it;

 

 

In addition, there are a number of global functions that allow you to work (load and save) groups of icons as one icon with several image options:

 

SaveIcons2Stream(icons, strm) - saves the icons specified in the icons array to the specified stream as a single icon with several image options. The array of icons should contain several icons of different sizes;

SaveIcons2File(icons, s) - similar to the previous one, but the multiple icon resource is saved in the file;

And one more global function for loading an icon:

LoadImgIcon(resName, sz) - loads an icon from the resource of the application itself by the name of the resource, as close as possible to the specified size (if 0, then the 32x32 icon is loaded by default);

 

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