Difference between revisions of "Cursor"

From Free Pascal wiki
Jump to navigationJump to search
(Cursor - property of the TCursor Object.)
(Cursor - property of the TCursor Object.)
Line 1: Line 1:
 
Cursor - property of the TCursor Object.
 
Cursor - property of the TCursor Object.
  
<delphi>
 
== Cursor Constants ==
 
  
crAppStart <= Arrow with small hour glass in the lower right corner.
+
'''Cursor Constants'''
crArrow <= Arrow
+
 
crCross <= Cross
+
* crAppStart <= Arrow with small hour glass in the lower right corner.<br>
crDefault <= Same as Arrow.
+
* crArrow <= Arrow<br>
crDrag <= Arrow with a dotted box going through the bottom part of the Arrow.
+
* crCross <= Cross<br>
crHandPoint <= Hand with pointing index finger (same as you would see when hovering over
+
* crDefault <= Same as Arrow.<br>
              a link in a browser).
+
* crDrag <= Arrow with a dotted box going through the bottom part of the Arrow.<br>
crHelp <= Arrow with a question mark to the right of it.
+
* crHandPoint <= Hand with pointing index finger (same as you would see when hovering over a link in a browser).<br>
crHourGlass <= Hour Glass
+
* crHelp <= Arrow with a question mark to the right of it.<br>
crHSplit <= Horizontal Split (A left arrow, two pipes in the center, and a right arrow.)
+
* crHourGlass <= Hour Glass<br>
crIBeam <= IBeam
+
* crHSplit <= Horizontal Split (A left arrow, two pipes in the center, and a right arrow.)<br>
crMultiDrag <= Same as crDrag but there are two boxes going through the bottom part of the Arrow.
+
* crIBeam <= IBeam<br>
crNo <= A black circle with a slash through it.
+
* crMultiDrag <= Same as crDrag but there are two boxes going through the bottom part of the Arrow.<br>
crNoDrop <= A white circle with a slash through it.
+
* crNo <= A black circle with a slash through it.<br>
crNone <= No cursor.  The mouse pointer is invisible.
+
* crNoDrop <= A white circle with a slash through it.<br>
crSizeAll <= A cross with arrows on the tips.
+
* crNone <= No cursor.  The mouse pointer is invisible.<br>
crSizeNESW <= An animated, double arrow cursor that is joined, pointing from North East to South West.  
+
* crSizeAll <= A cross with arrows on the tips.<br>
crSizeNS <= An animated, double arrow cursor that is joined, pointing from North to South.
+
* crSizeNESW <= An animated, double arrow cursor that is joined, pointing from North East to South West. <br>
crSizeNWSE <= An animated, double arrow cursor that is joined, pointing from North West to South West.
+
* crSizeNS <= An animated, double arrow cursor that is joined, pointing from North to South.<br>
crSizeWE <= An animated, double arrow cursor that is joined, pointing from West to East.
+
* crSizeNWSE <= An animated, double arrow cursor that is joined, pointing from North West to South West.<br>
crSQLWait <= An hour glass with the letters SQL beneath it.
+
* crSizeWE <= An animated, double arrow cursor that is joined, pointing from West to East.<br>
crUpArrow <= A black arrow pointing up.
+
* crSQLWait <= An hour glass with the letters SQL beneath it.<br>
crVSplit <= Vertical Split (A left arrow, two pipes in the center, and a right arrow.)
+
* crUpArrow <= A black arrow pointing up.<br>
 +
* crVSplit <= Vertical Split (A left arrow, two pipes in the center, and a right arrow.)
 +
 
  
</delphi>
+
<hr>
  
  
EXAMPLE 1: To View All The Cursor Types.
+
'''EXAMPLE 1: To View All The Cursor Types'''
  
 
(1) On Form1, drag a ComboBox control onto the Form.
 
(1) On Form1, drag a ComboBox control onto the Form.
Line 72: Line 72:
  
  
EXAMPLE 2: Change An Objects Cursor
+
<hr>
 +
 
 +
 
 +
'''EXAMPLE 2: Change An Objects Cursor'''
  
 
<delphi>
 
<delphi>
Line 88: Line 91:
 
</delphi>
 
</delphi>
  
EXAMPLE 3: Change All Controls To An Hour Glass, Except TBitBtn Controls.
+
 
 +
<hr>
 +
 
 +
 
 +
'''EXAMPLE 3: Change All Controls To An Hour Glass, Except TBitBtn Controls'''
  
 
<delphi>
 
<delphi>

Revision as of 09:53, 25 July 2010

Cursor - property of the TCursor Object.


Cursor Constants

  • crAppStart <= Arrow with small hour glass in the lower right corner.
  • crArrow <= Arrow
  • crCross <= Cross
  • crDefault <= Same as Arrow.
  • crDrag <= Arrow with a dotted box going through the bottom part of the Arrow.
  • crHandPoint <= Hand with pointing index finger (same as you would see when hovering over a link in a browser).
  • crHelp <= Arrow with a question mark to the right of it.
  • crHourGlass <= Hour Glass
  • crHSplit <= Horizontal Split (A left arrow, two pipes in the center, and a right arrow.)
  • crIBeam <= IBeam
  • crMultiDrag <= Same as crDrag but there are two boxes going through the bottom part of the Arrow.
  • crNo <= A black circle with a slash through it.
  • crNoDrop <= A white circle with a slash through it.
  • crNone <= No cursor. The mouse pointer is invisible.
  • crSizeAll <= A cross with arrows on the tips.
  • crSizeNESW <= An animated, double arrow cursor that is joined, pointing from North East to South West.
  • crSizeNS <= An animated, double arrow cursor that is joined, pointing from North to South.
  • crSizeNWSE <= An animated, double arrow cursor that is joined, pointing from North West to South West.
  • crSizeWE <= An animated, double arrow cursor that is joined, pointing from West to East.
  • crSQLWait <= An hour glass with the letters SQL beneath it.
  • crUpArrow <= A black arrow pointing up.
  • crVSplit <= Vertical Split (A left arrow, two pipes in the center, and a right arrow.)




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:

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:

<delphi> procedure TForm1.ComboBox1Change(Sender: TObject); begin

    Form1.Cursor := StringToCursor(ComboBox1.Text);

end; </delphi>

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

<delphi> procedure TForm1.FormCreate(Sender: TObject); begin

    Form1.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; </delphi>




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

<delphi> procedure TForm1.FormCreate(Sender: TObject); var

  I: Integer;

begin

    Form1.Cursor := crHourGlass;
    for I := 0 to Form1.ControlCount - 1 do
    begin
         if (Form1.Controls[I].ClassType <> TBitBtn) then
            Form1.Controls[I].Cursor := crHourGlass;
    end;

end; </delphi>

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

<delphi> procedure TForm1.FormCreate(Sender: TObject); var

  I: Integer;

begin

    Form1.Cursor := crHourGlass;
    for I := 0 to Form1.ControlCount - 1 do
    begin
         if (Form1.Controls[I].ClassType <> TBitBtn) then
            Form1.Controls[I].Cursor := crHourGlass;
    end;
    for I := 0 to Form1.GroupBox1.ControlCount - 1 do
    begin
         if (Form1.GroupBox1.Controls[I].ClassType <> TBitBtn) then
            Form1.GroupBox1.Controls[I].Cursor := crHourGlass;
    end;

end; </delphi>

With the above example, in which you had Form1, as well as other controls on the form such as Memo1, Edit1, Image1, 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.