Board index » delphi » Help needed with using animated cursors, please...

Help needed with using animated cursors, please...

I have a need for using Animate Cursors (*.ANI files) in a few of my
programs. I have figured out how to load from file the .ani cursor but
with MY users I don't want to take any chances and want to include the
file in a resource file and compile it with my executable.

What I need to know is:

        How can I put the .ani file in a resource file,
        How do I read the animated cursor from the resource?

If you have ANY suggestions they would be GREATLY appreciated. I have
found NO help on this topic at all so far.

Thanks,

Bill Artemik
Programmer/Analyst
Wakefield Engineering, Inc.
barte...@wakefield.com

Bill Artemik
--------------------
Programmer / Analyst
Wakefield Engineering, Inc.

barte...@wakefield.com

"There are THREE kinds of people in the world...
     Those that can count and those that can't."

 

Re:Help needed with using animated cursors, please...


Quote
>What I need to know is:

>       How can I put the .ani file in a resource file,

Create a "cursors.rc" file and add references to your cursors like this:

1       CURSOR  DISCARDABLE     "mycursor.cur"

Give each cursor a unique number. Compile the file with brcc32.exe and
link the resulting .res file into your application with the {$R }
compiler directive.

Quote
>       How do I read the animated cursor from the resource?

const
  crMyCursor = 1;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,
                                           MakeIntResource(crMyCursor));
  Cursor := crMyCursor;
end;

Note that the index of your cursor in the Screen.Cursors array does
not have to be the same as the index you gave the cursor in the .rc
file - I just do this for convenience.

Quote
>If you have ANY suggestions they would be GREATLY appreciated. I have
>found NO help on this topic at all so far.

Actually, there is a small amount of help under TScreen.Cursors
--
Jeremy Collins
Kansai Business Systems

(return address not altered 'coz I get spammed *whatever* I do!)

Re:Help needed with using animated cursors, please...


Thanks! I'll try this this morning. I don't know if I have brcc32.exe,
though...

Bill

On Fri, 17 Jul 1998 09:38:13 +0100, Jeremy Collins

Quote
<j...@jcollins.demon.co.uk> wrote:
>>What I need to know is:

>>       How can I put the .ani file in a resource file,

>Create a "cursors.rc" file and add references to your cursors like this:

>1       CURSOR  DISCARDABLE     "mycursor.cur"

>Give each cursor a unique number. Compile the file with brcc32.exe and
>link the resulting .res file into your application with the {$R }
>compiler directive.

>>       How do I read the animated cursor from the resource?

>const
>  crMyCursor = 1;
>procedure TForm1.FormCreate(Sender: TObject);
>begin
>  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,
>                                           MakeIntResource(crMyCursor));
>  Cursor := crMyCursor;
>end;

>Note that the index of your cursor in the Screen.Cursors array does
>not have to be the same as the index you gave the cursor in the .rc
>file - I just do this for convenience.

>>If you have ANY suggestions they would be GREATLY appreciated. I have
>>found NO help on this topic at all so far.

>Actually, there is a small amount of help under TScreen.Cursors

Bill
-------------------------------
Programmer/Analyst
Wakefield Engineering, Inc.
barte...@wakefield.com

"There are THREE kinds of people in the world...
     Those that can count and those that can't."

Re:Help needed with using animated cursors, please...


Jeremy:

This didn't work with Animated Cursors. Works fine with regular
cursors, though. What else could I do...?

Bill

On Fri, 17 Jul 1998 09:38:13 +0100, Jeremy Collins

Quote
<j...@jcollins.demon.co.uk> wrote:
>>What I need to know is:

>>       How can I put the .ani file in a resource file,

>Create a "cursors.rc" file and add references to your cursors like this:

>1       CURSOR  DISCARDABLE     "mycursor.cur"

>Give each cursor a unique number. Compile the file with brcc32.exe and
>link the resulting .res file into your application with the {$R }
>compiler directive.

>>       How do I read the animated cursor from the resource?

>const
>  crMyCursor = 1;
>procedure TForm1.FormCreate(Sender: TObject);
>begin
>  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,
>                                           MakeIntResource(crMyCursor));
>  Cursor := crMyCursor;
>end;

>Note that the index of your cursor in the Screen.Cursors array does
>not have to be the same as the index you gave the cursor in the .rc
>file - I just do this for convenience.

>>If you have ANY suggestions they would be GREATLY appreciated. I have
>>found NO help on this topic at all so far.

>Actually, there is a small amount of help under TScreen.Cursors

Bill
-------------------------------
Programmer/Analyst
Wakefield Engineering, Inc.
barte...@wakefield.com

"There are THREE kinds of people in the world...
     Those that can count and those that can't."

Re:Help needed with using animated cursors, please...


Bill,

Add the .ANI file to a custom resource file as type RC_DATA. At
runtime, load the resource into a TResourceStream and write it
to disk as an .ANI, and then use your current load from file
method. When your app terminates, just delete the file from disk.

Adding the .ANI to the resource is easy:

MYANICURSOR RC_DATA MyCursor.ANI

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
Bill Artemik wrote:

> Jeremy:

> This didn't work with Animated Cursors. Works fine with regular
> cursors, though. What else could I do...?

> Bill

> On Fri, 17 Jul 1998 09:38:13 +0100, Jeremy Collins
> <j...@jcollins.demon.co.uk> wrote:

> >>What I need to know is:

> >>       How can I put the .ani file in a resource file,

> >Create a "cursors.rc" file and add references to your cursors like this:

> >1       CURSOR  DISCARDABLE     "mycursor.cur"

> >Give each cursor a unique number. Compile the file with brcc32.exe and
> >link the resulting .res file into your application with the {$R }
> >compiler directive.

> >>       How do I read the animated cursor from the resource?

> >const
> >  crMyCursor = 1;
> >procedure TForm1.FormCreate(Sender: TObject);
> >begin
> >  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,
> >                                           MakeIntResource(crMyCursor));
> >  Cursor := crMyCursor;
> >end;

> >Note that the index of your cursor in the Screen.Cursors array does
> >not have to be the same as the index you gave the cursor in the .rc
> >file - I just do this for convenience.

> >>If you have ANY suggestions they would be GREATLY appreciated. I have
> >>found NO help on this topic at all so far.

> >Actually, there is a small amount of help under TScreen.Cursors

> Bill
> -------------------------------
> Programmer/Analyst
> Wakefield Engineering, Inc.
> barte...@wakefield.com

> "There are THREE kinds of people in the world...
>      Those that can count and those that can't."

Other Threads