Friday, September 7, 2018

DELPHI - How to load own (animated) cursor

There is a several steps:

1) Prepare cursor - here it is animated cursor in file "cursor_busy.ani".

2) Create file with .rc extension, write path to cursor to it.
CUR_ANIM 21 "c:\delphi\projects\project_name\cursors\cursor_busy.ani"

3) Add link to .rc file to project:
{$R 'myResources.res' 'myResources.rc'}

4) Define internal number for own cursor:
const
  crCursor_Busy = 115;

5) Load defined cursor to app:
const
  Screen.Cursors[ crCursor_Busy ] := LoadCursor( hInstance, 'CUR_ANIM' );

6) Now, when you use this code:
Screen.Cursor := crCursor_Busy;
..you will see this loaded (animated) cursor:

No comments:

Post a Comment