Board index » delphi » Animated Cursor

Animated Cursor

Hi all

I already know how to use an animated cursor in my
application, I got a sample here:

const crMyCursor = 1;
procedure TForm1.FormCreate(Sender: TObject);
begin
  // Load the cursor. Needs to be done only once
  Screen.Cursors[crMyCursor] :=
LoadCursorFromFile('c:\mystuff\mycursor.ani');
  // Use the cursor with this form
  Cursor := crMyCursor;
end;

What I don't know is: How can I put this cursor inside a .RES file, so I
don't need to ship the .ani file with my application? Is there any way to
put the .ani file inside my .exe? Thanks in advance...

JR

 

Re:Animated Cursor


Quote
JR wrote:
> What I don't know is: How can I put this cursor inside a .RES file, so I
> don't need to ship the .ani file with my application? Is there any way to
> put the .ani file inside my .exe? Thanks in advance...

I think "someone" write a faq or ti on this subject, so the info
should be available somewhere from the Delphi support web page..

The answer is no, unless you save the data from the res file to
a temp file, then load it.

Joe
--
Joe C. Hecht
joehe...@gte.net
(850) 689-0877 121 Louise Dr. Crestview, FL 32536
http://home1.gte.net/joehecht/index.htm

Re:Animated Cursor


I think I know what you have to do, but I can't tell you exactly off hand.
You need to use the Borland Resource Compiler.  It is BRCC32.EXE or
something similar.  You will find it in the \Bin folder. You have to create
a text file containing the parameters and after you have run the program (it
runs from a DOS prompt) you will have a .RES file you can include as normal
in your application and the data will be included in your executable.

Check the help or TI for the exact use of the compiler. There have been
threads on this before, so you might find something more exact elsewhere.

David Barnard

Re:Animated Cursor


Quote
>I think "someone" write a faq or ti on this subject, so the info
>should be available somewhere from the Delphi support web page..

Yep
I saw it.

Quote

>The answer is no, unless you save the data from the res file to
>a temp file, then load it.

Do u know how to do that? I compiled my .rc file with BRCC32.EXE and it
created the .res ok. Then I linked it to my application using:

{$R MyResource.RES}

But when I try to create a TResourceStream so I can save the resource of the
Cursor to a temp file, It raises an exception: 'Resource MyCursor not found'

My Code:

var
t : TResourceStream;
Begin
   t := TResourceStream.Create(hInstance,'MyCursor',RT_CURSOR);
// I tryed RT_RCDATA also, but it wont work to
   t.SaveToFile('Test.ani');
   T.Free;
End;

Quote
>Joe
>--
>Joe C. Hecht
>joehe...@gte.net
>(850) 689-0877 121 Louise Dr. Crestview, FL 32536
>http://home1.gte.net/joehecht/index.htm

Re:Animated Cursor


If I remember correctly, you need to name resources in all uppercase or your app
won't be able to find the resource in the resource file.
Luck,
DL
Quote
JR wrote:
> >I think "someone" write a faq or ti on this subject, so the info
> >should be available somewhere from the Delphi support web page..

> Yep
> I saw it.

> >The answer is no, unless you save the data from the res file to
> >a temp file, then load it.

> Do u know how to do that? I compiled my .rc file with BRCC32.EXE and it
> created the .res ok. Then I linked it to my application using:

> {$R MyResource.RES}

> But when I try to create a TResourceStream so I can save the resource of the
> Cursor to a temp file, It raises an exception: 'Resource MyCursor not found'

> My Code:

> var
> t : TResourceStream;
> Begin
>    t := TResourceStream.Create(hInstance,'MyCursor',RT_CURSOR);
> // I tryed RT_RCDATA also, but it wont work to
>    t.SaveToFile('Test.ani');
>    T.Free;
> End;

> >Joe
> >--
> >Joe C. Hecht
> >joehe...@gte.net
> >(850) 689-0877 121 Louise Dr. Crestview, FL 32536
> >http://home1.gte.net/joehecht/index.htm

Other Threads