Cursor: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Cursor
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Cursor - [[Property|property]] of the TCursor Object. | |
| 2 | + | ||
| 3 | + | ## List of cursor constants | |
| 4 | + | ||
| 5 | + | <table> | |
| 6 | + | <thead> | |
| 7 | + | <tr> | |
| 8 | + | <th><p>Constant</p></th> | |
| 9 | + | <th><p>Integer value</p></th> | |
| 10 | + | <th><p>Shape</p></th> | |
| 11 | + | </tr> | |
| 12 | + | </thead> | |
| 13 | + | <tbody> | |
| 14 | + | <tr> | |
| 15 | + | <td><p>crDefault</p></td> | |
| 16 | + | <td><p>0</p></td> | |
| 17 | + | <td><figure> | |
| 18 | + | <img src="crArrow.png" title="crArrow.png" /> | |
| 19 | + | <figcaption>crArrow.png</figcaption> | |
| 20 | + | </figure></td> | |
| 21 | + | </tr> | |
| 22 | + | <tr> | |
| 23 | + | <td><p>crNone</p></td> | |
| 24 | + | <td><p>-1</p></td> | |
| 25 | + | <td><p>Invisible mouse pointer</p></td> | |
| 26 | + | </tr> | |
| 27 | + | <tr> | |
| 28 | + | <td><p>crArrow</p></td> | |
| 29 | + | <td><p>-2</p></td> | |
| 30 | + | <td><figure> | |
| 31 | + | <img src="crArrow.png" title="crArrow.png" /> | |
| 32 | + | <figcaption>crArrow.png</figcaption> | |
| 33 | + | </figure></td> | |
| 34 | + | </tr> | |
| 35 | + | <tr> | |
| 36 | + | <td><p>crCross</p></td> | |
| 37 | + | <td><p>-3</p></td> | |
| 38 | + | <td><figure> | |
| 39 | + | <img src="crCross.png" title="crCross.png" /> | |
| 40 | + | <figcaption>crCross.png</figcaption> | |
| 41 | + | </figure></td> | |
| 42 | + | </tr> | |
| 43 | + | <tr> | |
| 44 | + | <td><p>crIBeam</p></td> | |
| 45 | + | <td><p>-4</p></td> | |
| 46 | + | <td><figure> | |
| 47 | + | <img src="crIBeam.png" title="crIBeam.png" /> | |
| 48 | + | <figcaption>crIBeam.png</figcaption> | |
| 49 | + | </figure></td> | |
| 50 | + | </tr> | |
| 51 | + | <tr> | |
| 52 | + | <td><p>crSize</p></td> | |
| 53 | + | <td><p>-22</p></td> | |
| 54 | + | <td><figure> | |
| 55 | + | <img src="crSize.png" title="crSize.png" /> | |
| 56 | + | <figcaption>crSize.png</figcaption> | |
| 57 | + | </figure></td> | |
| 58 | + | </tr> | |
| 59 | + | <tr> | |
| 60 | + | <td><p>crSizeNESW</p></td> | |
| 61 | + | <td><p>-6</p></td> | |
| 62 | + | <td><figure> | |
| 63 | + | <img src="crSizeNESW.png" title="crSizeNESW.png" /> | |
| 64 | + | <figcaption>crSizeNESW.png</figcaption> | |
| 65 | + | </figure></td> | |
| 66 | + | </tr> | |
| 67 | + | <tr> | |
| 68 | + | <td><p>crSizeNS</p></td> | |
| 69 | + | <td><p>-7</p></td> | |
| 70 | + | <td><figure> | |
| 71 | + | <img src="crSizeNS.png" title="crSizeNS.png" /> | |
| 72 | + | <figcaption>crSizeNS.png</figcaption> | |
| 73 | + | </figure></td> | |
| 74 | + | </tr> | |
| 75 | + | <tr> | |
| 76 | + | <td><p>crSizeNWSE</p></td> | |
| 77 | + | <td><p>-8</p></td> | |
| 78 | + | <td><figure> | |
| 79 | + | <img src="crSizeNWSE.png" title="crSizeNWSE.png" /> | |
| 80 | + | <figcaption>crSizeNWSE.png</figcaption> | |
| 81 | + | </figure></td> | |
| 82 | + | </tr> | |
| 83 | + | <tr> | |
| 84 | + | <td><p>crSizeWE</p></td> | |
| 85 | + | <td><p>-9</p></td> | |
| 86 | + | <td><figure> | |
| 87 | + | <img src="crSizeWE.png" title="crSizeWE.png" /> | |
| 88 | + | <figcaption>crSizeWE.png</figcaption> | |
| 89 | + | </figure></td> | |
| 90 | + | </tr> | |
| 91 | + | <tr> | |
| 92 | + | <td><p>crUpArrow</p></td> | |
| 93 | + | <td><p>-10</p></td> | |
| 94 | + | <td><p>|<img src="crUpArrow.png" title="crUpArrow.png" alt="crUpArrow.png" /></p></td> | |
| 95 | + | </tr> | |
| 96 | + | <tr> | |
| 97 | + | <td><p>crHourGlass</p></td> | |
| 98 | + | <td><p>-11</p></td> | |
| 99 | + | <td><figure> | |
| 100 | + | <img src="crHourGlass.png" title="crHourGlass.png" /> | |
| 101 | + | <figcaption>crHourGlass.png</figcaption> | |
| 102 | + | </figure></td> | |
| 103 | + | </tr> | |
| 104 | + | <tr> | |
| 105 | + | <td><p>crDrag</p></td> | |
| 106 | + | <td><p>-12</p></td> | |
| 107 | + | <td><figure> | |
| 108 | + | <img src="crDrag.png" title="crDrag.png" /> | |
| 109 | + | <figcaption>crDrag.png</figcaption> | |
| 110 | + | </figure></td> | |
| 111 | + | </tr> | |
| 112 | + | <tr> | |
| 113 | + | <td><p>crNoDrop</p></td> | |
| 114 | + | <td><p>-13</p></td> | |
| 115 | + | <td><p>|<img src="crNoDrop.png" title="crNoDrop.png" alt="crNoDrop.png" /></p></td> | |
| 116 | + | </tr> | |
| 117 | + | <tr> | |
| 118 | + | <td><p>crHSplit</p></td> | |
| 119 | + | <td><p>-14</p></td> | |
| 120 | + | <td><figure> | |
| 121 | + | <img src="crHSplit.png" title="crHSplit.png" /> | |
| 122 | + | <figcaption>crHSplit.png</figcaption> | |
| 123 | + | </figure></td> | |
| 124 | + | </tr> | |
| 125 | + | <tr> | |
| 126 | + | <td><p>crVSplit</p></td> | |
| 127 | + | <td><p>-15</p></td> | |
| 128 | + | <td><p>|<img src="crVSplit.png" title="crVSplit.png" alt="crVSplit.png" /></p></td> | |
| 129 | + | </tr> | |
| 130 | + | <tr> | |
| 131 | + | <td><p>crMultiDrag</p></td> | |
| 132 | + | <td><p>-16</p></td> | |
| 133 | + | <td><figure> | |
| 134 | + | <img src="crMultiDrag.png" title="crMultiDrag.png" /> | |
| 135 | + | <figcaption>crMultiDrag.png</figcaption> | |
| 136 | + | </figure></td> | |
| 137 | + | </tr> | |
| 138 | + | <tr> | |
| 139 | + | <td><p>crSQLWait</p></td> | |
| 140 | + | <td><p>-17</p></td> | |
| 141 | + | <td><figure> | |
| 142 | + | <img src="crSQLWait.png" title="crSQLWait.png" /> | |
| 143 | + | <figcaption>crSQLWait.png</figcaption> | |
| 144 | + | </figure></td> | |
| 145 | + | </tr> | |
| 146 | + | <tr> | |
| 147 | + | <td><p>crNo</p></td> | |
| 148 | + | <td><p>-18</p></td> | |
| 149 | + | <td><figure> | |
| 150 | + | <img src="CrNo.png" title="CrNo.png" /> | |
| 151 | + | <figcaption>CrNo.png</figcaption> | |
| 152 | + | </figure></td> | |
| 153 | + | </tr> | |
| 154 | + | <tr> | |
| 155 | + | <td><p>crAppStart</p></td> | |
| 156 | + | <td><p>-19</p></td> | |
| 157 | + | <td><figure> | |
| 158 | + | <img src="crAppStart.png" title="crAppStart.png" /> | |
| 159 | + | <figcaption>crAppStart.png</figcaption> | |
| 160 | + | </figure></td> | |
| 161 | + | </tr> | |
| 162 | + | <tr> | |
| 163 | + | <td><p>crHelp</p></td> | |
| 164 | + | <td><p>-20</p></td> | |
| 165 | + | <td><figure> | |
| 166 | + | <img src="crHelp.png" title="crHelp.png" /> | |
| 167 | + | <figcaption>crHelp.png</figcaption> | |
| 168 | + | </figure></td> | |
| 169 | + | </tr> | |
| 170 | + | <tr> | |
| 171 | + | <td><p>crHandPoint</p></td> | |
| 172 | + | <td><p>-21</p></td> | |
| 173 | + | <td><figure> | |
| 174 | + | <img src="crHandPoint.png" title="crHandPoint.png" /> | |
| 175 | + | <figcaption>crHandPoint.png</figcaption> | |
| 176 | + | </figure></td> | |
| 177 | + | </tr> | |
| 178 | + | </tbody> | |
| 179 | + | </table> | |
| 180 | + | ||
| 181 | + | ## Examples | |
| 182 | + | ||
| 183 | + | ### Example 1: To View All The Cursor Types | |
| 184 | + | ||
| 185 | + | \(1\) On [[TForm|Form1]], drag a [[TComboBox|ComboBox]] control onto the Form. | |
| 186 | + | ||
| 187 | + | \(2\) Set the ComboBox1, Items (TStrings) to the following: | |
| 188 | + | ||
| 189 | + | ``` pascal | |
| 190 | + | crAppStart | |
| 191 | + | crArrow | |
| 192 | + | crCross | |
| 193 | + | crDefault | |
| 194 | + | crDrag | |
| 195 | + | crHandPoint | |
| 196 | + | crHelp | |
| 197 | + | crHourGlass | |
| 198 | + | crHSplit | |
| 199 | + | crIBeam | |
| 200 | + | crMultiDrag | |
| 201 | + | crNo | |
| 202 | + | crNoDrop | |
| 203 | + | crNone | |
| 204 | + | crSizeAll | |
| 205 | + | crSizeNESW | |
| 206 | + | crSizeNS | |
| 207 | + | crSizeNWSE | |
| 208 | + | crSizeWE | |
| 209 | + | crSQLWait | |
| 210 | + | crUpArrow | |
| 211 | + | crVSplit | |
| 212 | + | ``` | |
| 213 | + | ||
| 214 | + | \(3\) On the ComboBox1Change procedure add this code: | |
| 215 | + | ||
| 216 | + | ``` pascal | |
| 217 | + | procedure TForm1.ComboBox1Change(Sender: TObject); | |
| 218 | + | begin | |
| 219 | + | Cursor := StringToCursor(ComboBox1.Text); | |
| 220 | + | end; | |
| 221 | + | ``` | |
| 222 | + | ||
| 223 | + | 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). | |
| 224 | + | ||
| 225 | + | ### Example 2: Change An Objects Cursor | |
| 226 | + | ||
| 227 | + | ``` pascal | |
| 228 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 229 | + | begin | |
| 230 | + | Cursor := crHourGlass; | |
| 231 | + | // Changes the Form1 cursor to an hour glass. | |
| 232 | + | ||
| 233 | + | Button1.Cursor := crHourGlass; | |
| 234 | + | // Changes the Button1 cursor to an hour glass. | |
| 235 | + | ||
| 236 | + | Memo1.Cursor := crHourGlass; | |
| 237 | + | // Changes the Memo1 cursor to an hour glass. | |
| 238 | + | end; | |
| 239 | + | ``` | |
| 240 | + | ||
| 241 | + | ### Example 3: Change All Controls To An Hour Glass, Except TBitBtn Controls | |
| 242 | + | ||
| 243 | + | ``` pascal | |
| 244 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 245 | + | var | |
| 246 | + | I: Integer; | |
| 247 | + | begin | |
| 248 | + | Cursor := crHourGlass; | |
| 249 | + | for I := 0 to ControlCount - 1 do | |
| 250 | + | begin | |
| 251 | + | if (Controls[I].ClassType <> TBitBtn) then | |
| 252 | + | Controls[I].Cursor := crHourGlass; | |
| 253 | + | end; | |
| 254 | + | end; | |
| 255 | + | ``` | |
| 256 | + | ||
| 257 | + | However, if you had a GroupBox, you would have to address the controls within it separately. | |
| 258 | + | ||
| 259 | + | ``` pascal | |
| 260 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 261 | + | var | |
| 262 | + | I: Integer; | |
| 263 | + | begin | |
| 264 | + | Cursor := crHourGlass; | |
| 265 | + | for I := 0 to ControlCount - 1 do | |
| 266 | + | begin | |
| 267 | + | if (Controls[I].ClassType <> TBitBtn) then | |
| 268 | + | Controls[I].Cursor := crHourGlass; | |
| 269 | + | end; | |
| 270 | + | for I := 0 to GroupBox1.ControlCount - 1 do | |
| 271 | + | begin | |
| 272 | + | if (GroupBox1.Controls[I].ClassType <> TBitBtn) then | |
| 273 | + | GroupBox1.Controls[I].Cursor := crHourGlass; | |
| 274 | + | end; | |
| 275 | + | end; | |
| 276 | + | ``` | |
| 277 | + | ||
| 278 | + | With the above example, in which you had Form1, as well as other controls on the form such as [[TMemo|Memo]], [[TEdit|Edit]], [[TImage|Image]], [[TBitBtn|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]]. | |
| 279 | + | ||
| 280 | + | --- | |
| 281 | + | *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](/wiki-contact).* |
