| View previous topic :: View next topic |
| Author |
Message |
HF Guest
|
Posted: Mon Feb 06, 2006 3:00 pm Post subject: HInstance of Package |
|
|
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
|
Posted: Mon Feb 06, 2006 7:00 pm Post subject: Re: HInstance of Package |
|
|
"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
|
Posted: Mon Feb 06, 2006 8:01 pm Post subject: Re: HInstance of Package |
|
|
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
|
Posted: Mon Feb 06, 2006 8:01 pm Post subject: Re: HInstance of Package |
|
|
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
|
Posted: Mon Feb 06, 2006 8:01 pm Post subject: Re: HInstance of Package |
|
|
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
|
Posted: Mon Feb 06, 2006 8:01 pm Post subject: Re: HInstance of Package |
|
|
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
|
Posted: Mon Feb 06, 2006 8:01 pm Post subject: Re: HInstance of Package |
|
|
"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
|
Posted: Mon Feb 06, 2006 9:00 pm Post subject: Re: HInstance of Package |
|
|
"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
|
Posted: Tue Feb 07, 2006 1:01 am Post subject: Re: HInstance of Package |
|
|
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 |
|
 |
|