To add a cursor to your application you need to create a .res file with the cursors in it.
For this example I used Borlands
Image Editor program that comes with Delphi.
First open Image Editor. Next go to File | New | Resource File (.res). Right-click on the word Contents which is in the new .res file window (Currently Untitled.res) and then go to New and click on Cursor. Double-click on the word Cursor1 and the image editor appears. You can draw your own cursor or you can open a cursor file and select all, copy and then paste this into the .res cursor image space. After you have your first cursor you can create a second cursor. I named the cursors for this example:
|
Below is all the code used in this example.
First we add these constants:
const crCurone = 1;
const crCurtwo = 2;
We must also add extras.res so that the
.res is loaded.
Here is how we do it:
{$R extras.res}
In the example code below we use Button2 to load and set the cursor to the first cursor, CURONE, and Button3 to load and set CURTWO.
Button1 is used to set the cursor back to the default cursor crDefault.
As you can see from the code you
shouldn't
have any problems trying out this example.
unit Unit1; interface uses
type
const crCurone = 1;
var Form1: TForm1; implementation {$R *.DFM} {$R extras.res} procedure
TForm1.Button1Click(Sender: TObject);
procedure
TForm1.Button2Click(Sender: TObject);
procedure
TForm1.Button3Click(Sender: TObject);
end.
|