Help & Manual authoring tool
This article explains how to embed your own cursors in your Delphi application

Using custom cursors

Copyright © 2000 Ernesto De Spirito

KnowledgeBase Vortex 2.9

To use custom cursors in your application you have to follow these steps:

1. Create the cursors and save them in a resource file. You can use the Image Editor that comes with Delphi for this purpose.

2. In the interface section of any unit of your project declare the constants to refer to your cursors in code. This is not required, but it will improve the readability of your code, so it is higly recommended.

These constans must be possitive integers. For example:

const
  crFinger = 1;
  crPower = 2;

3. In the initialization section of this unit, or anywhere in your project before you attempt to use your cursors, you have to load the cursors from the resource file. For example:

  uses Windows;

  ...

  {$R Cursors.res}
  Screen.Cursors[crFinger] := LoadCursor(hInstance, 'FINGER');
  Screen.Cursors[crPower] := LoadCursor(hInstance, 'POWER');

Here we assumed "Cursors.res" is the resource file where you saved your cursors, and that FINGER and POWER are the names you saved them under.

 
This is it. You can use these cursors in the same you would use the predefined cursors. For example:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Self.Cursor := crPower;
  Label1.Cursor := crFinger;
end;

You can also set the Cursor and DragCursor properties of a component at design-time using the Object Inspector. The only drawback is that you can't use the constants names (for example crFinger and crPower) but their values (for example 1 and 2).

JfControls Library - for Delphi and C++ Builder
Copyright © 2000/2006 Ernesto De Spirito.   All rights reserved.