🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Asger Jorgensen Sat, 21 Jul 2007 11:57
Loading from resource ??
#1498
Author: Asger Jorgensen
Date: Sat, 21 Jul 2007 11:57
53 lines
1999 bytes
Hi there 

I am trying to loaad an animated cursor from resource,
this is what i've done.

The .rh file:

#ifndef ICONS_RH
#define ICONS_RH

#define ID_CURSOR_WORKING  1002
#endif
//---------------------------

The .rc file:

#include "Icons.rh"

ID_CURSOR_WORKING  ANICURSOR "Abe.ani"

//---------------------------

I have added the .rc file to my project and the exe file 
is bigger now.

in the Form::OnShow i do:

HCURSOR hCursor = LoadCursor((void*)HInstance,
                  MAKEINTRESOURCE(ID_CURSOR_WORKING));

but hCursor is NULL.

If i do this:
HCURSOR hCursor = LoadCursorFromFile(CursorFile.c_str());

every thing works fine.

I have also tryed:
HRSRC hRsrc = FindResource( HInstance,	
    MAKEINTRESOURCE(ID_CURSOR_WORKING),	
    RT_ANICURSOR 	
   );
but FindResource also returns NULL

when I look at my exe file with the XN Resource Editor
I can see that there is a group called ANICURSOR and a lot of data
under the ID 1002

Anybody who knows what I am doing wrong ??


Thanks in advance
Asger
Re: Loading from resource ??
#1499
Author: Dennis Jones
Date: Sat, 21 Jul 2007 16:25
42 lines
1986 bytes
"Asger Jorgensen" <Junk@Asger-P.dk> wrote in message 
news:MPG.210c130d589713669897af@newsgroups.borland.com...
> Hi there
>
> I am trying to loaad an animated cursor from resource,
> this is what i've done.
>
> The .rh file:
>
> #ifndef ICONS_RH
> #define ICONS_RH
>
> #define ID_CURSOR_WORKING  1002
> #endif
> //---------------------------
>
> The .rc file:
>
> #include "Icons.rh"
>
> ID_CURSOR_WORKING  ANICURSOR "Abe.ani"

That looks wrong.  You are using the previously #defined integer value as 
the name of the resource.  I don't have a whole lot of experience with 
resources, but in my RC files, the same thing might look like:

// define a name for the 'working' cursor
CURSOR_WORKING ANICURSOR "Abe.ani"

Then in my code:

LoadCursor( (void *)Hinstance, "CURSOR_WORKING" );

or:

FindResource( (void *)HInstance, "CURSOR_WORKING", RT_ANICURSOR );

Note that I don't have to use MAKEINTRESOURCE (the point of which I've never 
understood anyway!).

- Dennis 
Re: Loading from resource ??
#1500
Author: Ed Mulroy [TeamB]
Date: Sat, 21 Jul 2007 17:03
13 lines
1465 bytes
MAKEINTRESOUCE creates a number and casts it to a char* pointer.

It is used when working with most RC files because labeling a resource with 
a character string both uses much more memory and slows access compared with 
giving it a number for an ID.

.  Ed

> Dennis Jones wrote in message
> news:46a23395$1@newsgroups.borland.com...
> ...
> Note that I don't have to use MAKEINTRESOURCE (the point of which I've 
> never understood anyway!).
Re: Loading from resource ??
#1501
Author: Asger Jorgensen
Date: Sat, 21 Jul 2007 17:38
15 lines
1252 bytes
Hi Dennis

Thanks for trying, but that was not what is wrong.:(

About doing it the way I'm doing:
Thats just how I have seen it done, and not knowing any better.;-)

I tryed Your way and mine with a normal cursor file, and they
both work, but with an animated cursor, there is no luck.

Any other suggestions ?

Thanks in advance
Kind regards
Asger
Re: Loading from resource ??
#1502
Author: Bob Gonder
Date: Sat, 21 Jul 2007 17:43
20 lines
1403 bytes
Asger Jorgensen wrote:

>#define ID_CURSOR_WORKING  1002
>#endif
>
>ID_CURSOR_WORKING  ANICURSOR "Abe.ani"

This is from an old group message (2000)

#define ANICURSOR 21
10 ANICURSOR "Abe.ani"

Also, same thread, this:
Win 9x doesn't load animated cursors from resources--only from files.

Here's a Delphi version:
http://www.delphiforfun.org/Programs/Delphi_Techniques/AnimatedCursors.htm

Here's a way to do it using RCDATA instead.
http://tinyurl.com/3a748q
Re: Loading from resource ??
#1503
Author: Asger Jorgensen
Date: Sat, 21 Jul 2007 18:44
14 lines
1216 bytes
Hi Bob

That last link defenetly looks like a way to go.
Thats what I call a work arround..;-)

I don't know about win9x, but xp and 2000 defenetly
don't load animated cursors from resource.

Thanks for the help
Best regards
Asger

> Here's a way to do it using RCDATA instead.
> http://tinyurl.com/3a748q
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads