BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HInstance of Package

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
HF
Guest





PostPosted: Mon Feb 06, 2006 3:00 pm    Post subject: HInstance of Package Reply with quote



Hello all,

I have a package which contains a component plus some resources(bitmaps).In
real time i want to access these bitmaps
//**************************************
Graphics::TBitmap* bb = new Graphics::TBitmap();
bb->LoadFromResourceName((int)HInstance ,"RES1");
....... some code .....
delete bb;
//**************************************

I get Exception Error in real time "resource RES1 not found".
HInstance is of the main application and cannot find RES1.How can I access
the package to retrieve RES1 ?

Thanks in advance
BCB 5 Pro
Back to top
Dennis Jones
Guest





PostPosted: Mon Feb 06, 2006 7:00 pm    Post subject: Re: HInstance of Package Reply with quote



"HF" <ola (AT) ola (DOT) gr> wrote in message news:43e75c95 (AT) newsgroups (DOT) borland.com...
Quote:
Hello all,

I have a package which contains a component plus some
resources(bitmaps).In
real time i want to access these bitmaps
//**************************************
Graphics::TBitmap* bb = new Graphics::TBitmap();
bb->LoadFromResourceName((int)HInstance ,"RES1");
...... some code .....
delete bb;
//**************************************

I get Exception Error in real time "resource RES1 not found".
HInstance is of the main application and cannot find RES1.How can I
access
the package to retrieve RES1 ?

If you know the name of the module that contains the resource, you can use
GetModuleHandle() to get its instance handle and use that to load the
resource. If you do not know the name of the module, you have to enumerate
all of the modules loaded by the application (see LibModuleList) and try
each one until you find the resource you are looking for.

- Dennis
Back to top
HF
Guest





PostPosted: Mon Feb 06, 2006 8:01 pm    Post subject: Re: HInstance of Package Reply with quote



thanks guys,

No the code is
bb->LoadFromResourceName((int)HInstance ,"RES1");

I checked my .exe file with resource editor and doesn't contain the bitmap.
Instead the package (bpl) it contains the bitmap.So the problem is why
during built , final .exe doesn't take the bitmap resource from package.azny
idea ?

Ο "Jonathan Benedicto" <invalid (AT) nobody (DOT) com> έγραψε στο μήνυμα
news:43e79cb8$1 (AT) newsgroups (DOT) borland.com...
Quote:
Bob Gonder wrote:
Try adding a capital L after then name as in "RES1"L

Isn't it before the name ? Eg:

L"RES1"

Jonathan
Back to top
Bob Gonder
Guest





PostPosted: Mon Feb 06, 2006 8:01 pm    Post subject: Re: HInstance of Package Reply with quote

HF wrote:

Quote:
bb->LoadFromResourceName((int)HInstance ,"RES1");

I get Exception Error in real time "resource RES1 not found".
HInstance is of the main application and cannot find RES1.How can I access
the package to retrieve RES1 ?

Try adding a capital L after then name as in "RES1"L

(Resource names are wide-char)
Back to top
Jonathan Benedicto
Guest





PostPosted: Mon Feb 06, 2006 8:01 pm    Post subject: Re: HInstance of Package Reply with quote

Bob Gonder wrote:
Quote:
Try adding a capital L after then name as in "RES1"L

Isn't it before the name ? Eg:

L"RES1"

Jonathan
Back to top
Jonathan Benedicto
Guest





PostPosted: Mon Feb 06, 2006 8:01 pm    Post subject: Re: HInstance of Package Reply with quote

Dennis Jones wrote:
Quote:
It's not supposed to. If you want the bitmap to be in the EXE, you have
to
add the resource to the EXE's project. If the resource is in the
package's
project, then you have to load the bitmap from the package, not the EXE.

I think that this depends on whether the package is linked statically or
dynamically. A quick Google turned up that you probably need to add #pragma
resource "xxx.res" to the component's .cpp file.

HTH

Jonathan
Back to top
Dennis Jones
Guest





PostPosted: Mon Feb 06, 2006 8:01 pm    Post subject: Re: HInstance of Package Reply with quote

"HF" <ola (AT) ola (DOT) gr> wrote in message news:43e79f6a (AT) newsgroups (DOT) borland.com...
Quote:
thanks guys,

No the code is
bb->LoadFromResourceName((int)HInstance ,"RES1");

I checked my .exe file with resource editor and doesn't contain the
bitmap.
Instead the package (bpl) it contains the bitmap.So the problem is why
during built , final .exe doesn't take the bitmap resource from
package.azny
idea ?

It's not supposed to. If you want the bitmap to be in the EXE, you have to
add the resource to the EXE's project. If the resource is in the package's
project, then you have to load the bitmap from the package, not the EXE.
See my first reply for how to do that.

- Dennis
Back to top
Dennis Jones
Guest





PostPosted: Mon Feb 06, 2006 9:00 pm    Post subject: Re: HInstance of Package Reply with quote

"Jonathan Benedicto" <invalid (AT) nobody (DOT) com> wrote in message
news:43e7a6e8 (AT) newsgroups (DOT) borland.com...
Quote:
Dennis Jones wrote:
It's not supposed to. If you want the bitmap to be in the EXE, you have
to
add the resource to the EXE's project. If the resource is in the
package's
project, then you have to load the bitmap from the package, not the EXE.

I think that this depends on whether the package is linked statically or
dynamically. A quick Google turned up that you probably need to add
#pragma
resource "xxx.res" to the component's .cpp file.

Ah, yes, there are some oddities when using resources in packages that are
linked statically, and as I recall, that just might be one of them. If the
package is linked statically, then it's a matter of figuring out how to make
sure the EXE gets the resource, and I think you're right that pragma is the
solution. If the package is linked dynamically however, then I think the
only option is to load the resource from the package directly using its
instance handle.

- Dennis
Back to top
HF
Guest





PostPosted: Tue Feb 07, 2006 1:01 am    Post subject: Re: HInstance of Package Reply with quote

Ok . resolved
Instead of adding the .rc or .res via the IDE to the package
I added it with #pragma resource "icons.res" in the unit.cpp (not the
package source file)
and it showed that is ok during building the calling application ,when asked
for icons.res to link it.

thanks guys.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.