Unfortunately, FireMonkey does not support custom cursors. This has already been filed as a feature request in Quality Portal:
RSP-17651 Cannot load custom cursors in Firemonkey.
With that said, the code you showed would not work in VCL. LoadCursorFromFile()
returns an HCURSOR
handle, but the TControl.Cursor
property expects an index value from the TCursor
enum instead. They are not the same thing. When loading a custom cursor, you must add it to the TScreen.Cursors[]
list. This is clearly stated in the documentation:
Vcl.Controls.TControl.Cursor
The value of Cursor is the index of the cursor in the list of cursors maintained by the global variable, Screen. In addition to the built-in cursors provided by TScreen, applications can add custom cursors to the list.
Vcl.Forms.TScreen.Cursors
Custom cursors can be added to the Cursors property for use by the application or any of its controls. To add a custom cursor to an application, you can ...:
...
2. Declare a cursor constant with a value that does not conflict with an existing cursor constant.
...
4. Set the Cursors property, indexed by the newly declared cursor constant, to the handle obtained from LoadCursor.
For example:
const
mycursor: TCursor = 1; // built-in values are <= 0, user-defined values are > 0
procedure Tform1.Button1Click(Sender: TObject);
begin
Screen.Cursors[mycursor] := LoadCursorFromFile('C:\...\Arrow.cur');
Button1.Cursor := mycursor;
end;