Sign in Join
Wiki copytemporary

Cursor

Deutsch · English · Suomi

Cursor - property of the TCursor Object.

List of cursor constants

Constant Integer value Shape
crDefault 0
crNone -1 Invisible mouse pointer
crArrow -2
crCross -3
crIBeam -4
crSize -22
crSizeNESW -6
crSizeNS -7
crSizeNWSE -8
crSizeWE -9
crUpArrow -10 |
crHourGlass -11
crDrag -12
crNoDrop -13 |
crHSplit -14
crVSplit -15 |
crMultiDrag -16
crSQLWait -17
crNo -18
crAppStart -19
crHelp -20
crHandPoint -21

Examples

Example 1: To View All The Cursor Types

(1) On Form1, drag a ComboBox control onto the Form.

(2) Set the ComboBox1, Items (TStrings) to the following:

pascal
crAppStart
crArrow
crCross
crDefault
crDrag
crHandPoint
crHelp
crHourGlass
crHSplit
crIBeam
crMultiDrag
crNo
crNoDrop
crNone
crSizeAll
crSizeNESW
crSizeNS
crSizeNWSE
crSizeWE
crSQLWait
crUpArrow
crVSplit

(3) On the ComboBox1Change procedure add this code:

pascal
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
     Cursor := StringToCursor(ComboBox1.Text);
end;

This will allow you to select the cursor type from the ComboBox and see it when you move the mouse over the Form. Only when you hover over the ComboBox will the cursor return to the default (crDefault).

Example 2: Change An Objects Cursor

pascal
procedure TForm1.FormCreate(Sender: TObject);
begin
     Cursor := crHourGlass;
     // Changes the Form1 cursor to an hour glass.

     Button1.Cursor := crHourGlass;
     // Changes the Button1 cursor to an hour glass.

     Memo1.Cursor := crHourGlass;
     // Changes the Memo1 cursor to an hour glass.
end;

Example 3: Change All Controls To An Hour Glass, Except TBitBtn Controls

pascal
procedure TForm1.FormCreate(Sender: TObject);
var
   I: Integer;
begin
     Cursor := crHourGlass;
     for I := 0 to ControlCount - 1 do
     begin
          if (Controls[I].ClassType <> TBitBtn) then
             Controls[I].Cursor := crHourGlass;
     end;
end;

However, if you had a GroupBox, you would have to address the controls within it separately.

pascal
procedure TForm1.FormCreate(Sender: TObject);
var
   I: Integer;
begin
     Cursor := crHourGlass;
     for I := 0 to ControlCount - 1 do
     begin
          if (Controls[I].ClassType <> TBitBtn) then
             Controls[I].Cursor := crHourGlass;
     end;
     for I := 0 to GroupBox1.ControlCount - 1 do
     begin
          if (GroupBox1.Controls[I].ClassType <> TBitBtn) then
             GroupBox1.Controls[I].Cursor := crHourGlass;
     end;
end;

With the above example, in which you had Form1, as well as other controls on the form such as Memo, Edit, Image, BitBtn, etc., this would change all but the BitBtn controls to the Hour Glass. There are controls such as the TGroupBox, TPanel, that act as individual containers for controls, and these items must be addresses separately from the main Form in order to change their internal control set to a different cursor at runtime.


From the Free Pascal wiki, page "Cursor", as it stood on 2020-11-12 after a change by Arent, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.