Rx Clip Icons

RX Library

UNIT ClipIcon

Const
WaitCursor

Routine
ActivatePrevInstance
ActivateWindow
AllocMemo
AnsiUpperFirstChar

Type
TFillDirection
TVertAlignment


Const CF_ICON
Declaration: CF_ICON: Word = 0;;

This is the registered custom clipboard format for Windows icon graphic. This constatnt can be used to find out if a icon format is available on the Clipboard with the HasFormat method.


Routine AssignClipboardIcon
Declaration: procedure AssignClipboardIcon(Icon: TIcon);

AssignClipboardIcon retrieves icon image from the Clipboard when Clipboard has format CF_ICON, and copies it to a icon object named Icon.

Use the TClipboard.HasFormat method to determine whether the information on the clipboard uses a format compatible with the icon object (CF_ICON).
You can place icon in the Clipboard by calling CopyIconToClipboard procedure.

AssignClipboardIcon example:

begin
__{...}
__if Clipboard.HasFormat(CF_ICON) then
____AssignClipboardIcon(Application.Icon);
__{...}
end;


Routine CopyIconToClipboard
Declaration: procedure CopyIconToClipboard(Icon: TIcon; BackColor: TColor);

CopyIconToClipboard copies the icon to the Clipboard. This function places the data in CF_ICON format and assosiated bitmap to the clipboard. BackColor is color to fill background when creating bitmap from the icon.

Use CreateIconFromClipboard or AssignClipboardIcon to retrieve icon from the Clipboard.

CopyIconToClipboard example:

var Icon: TIcon;
begin
__...
__CopyIconToClipboard(Icon, clBtnFace);
end;


Routine CreateIconFromClipboard
Declaration: function CreateIconFromClipboard: TIcon;

CreateIconFromClipboard retrieves icon image from the Clipboard when Clipboard has format CF_ICON, and creates new icon object. You must destroy created object after using it. When Clipboard has not icon data, this function returns nil.

Use the TClipboard.HasFormat method to determine whether the information on the clipboard uses a format compatible with the icon object (CF_ICON).

You can place icon in the Clipboard by calling CopyIconToClipboard procedure.

CreateIconFromClipboard example:

var Icon: TIcon;
begin
__...
__Icon := CreateIconFromClipboard;
__try
____{ using the icon }
__finally
____Icon.Free;
__end;
__...
end;


Routine CreateRealSizeIcon
Declaration: function CreateRealSizeIcon(Icon: TIcon): HIcon;

Creates new icon handle from Icon object that has the "real" size. If the function succeeds, the return value is the handle of an icon. If the function fails, the return value is 0.

Before closing, an application must call the Windows API DestroyIcon function to free system resources associated with the icon.

CreateRealSizeIcon example:
var
__Ico: HIcon;
begin
__Ico := CreateRealSizeIcon(Form1.Icon);
__try
____{ ... }
__finally
____DestroyIcon(Ico);
__end;
end;


Routine DrawRealSizeIcon
Declaration: procedure DrawRealSizeIcon(Canvas: TCanvas; Icon: TIcon; X, Y: Integer);

Renders the icon specified by the Icon parameter on the Canvas at the location given by the coordinates (X, Y) using real icon size (for example, you can draw icon 16x16 or 48x48 pixels).

Standard TIcon class always renders icon using Windows metrics SM_CXICON, SM_CYICON.

NOTE. In 16-bit version this procedure is "stub" and is equivalent to standard TCanvas.Draw method.

DrawRealSizeIcon example:
DrawRealSizeIcon(Canvas, Icon, 0, 0);


Routine GetIconSize
Declaration: procedure GetIconSize(Icon: HICON; var W, H: Integer);

The GetIconSize procedure retrieves information about width and height (as W and H parameter correspondingly) of the specified icon.

This procedure work correctly in 32-bit version only. In Delphi 1.0 this procedure is "stub" and always retrieves SM_CXICON, SM_CYICON values.

GetIconSize example:
GetIconSize(Icon.Handle, W, H);


Index Page | About | Download
Creation Date: 4 Feb 1998 | Last Update: 16 Mar 2000