![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
Q: Change the mouse cursor.Answer: Most VCL controls have a Cursor property that allows you to change the mouse cursor for that control's air space. This works OK when you need to change the cursor for one control, but it falls short when you need to set the cursor for the entire screen. For example, if you set the cursor property of a form, the cursor will change back when it passes over a control in the form. To change the cursor for the entire screen, use the Cursor property of the global screen property.
The list below illustrates the stock values that you can assign to
Screen->Cursor.
The steps below describe how to assign a custom cursor, instead of using the stock cursors. Step 1: Use the image editor to create a RES file that contains your custom cursor. Add the RES file to the project. Step 2: The available screen cursors, include the stock cursors listed above, are all contained in the Cursors array property of TScreen. You must load your cursor and add it to this array before you can use it. Declare a constant that will serve as your cursor identifer and array index. Then load in the cursor using the declared index value. const TCursor crMyCustomCursor=1; // ID for custom cursor __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { // load the cursor into the array. // "CURSOR1" is the string identifer set using the Image Editor Screen->Cursors[crMyCustomCursor]=LoadCursor((void*) HInstance,"CURSOR1"); } Step 3: Assign the new cursor the to Screen->Cursor property whenever you want it to be the mouse cursor. Screen->Cursor = crMyCustomCursor; | ||||||
All rights reserved. |