Link to home
Start Free TrialLog in
Avatar of edy081298
edy081298

asked on

C++Builder - Component resource images

I'm coding a graphic component for C++Builder 1.0. I store the images in a .DCR file and the library rebuilds ok, but when the program runs it can't find the resource images.

A partial solution is to store the images in a .res file, then rebuild the library and add this .res file to the project.

I want the resources to be linked automatically when I use my component, is there any way to do this?
Avatar of rwilson032697
rwilson032697

You need to add thn to a .RES file and add the .RES file to the project.

The .DCR files (stands for Delphi Component Resource!) are only used for the icons that represent the component in the pallete.

Cheers,

Raymond.
Yes, I know that it works adding the .RES file to the project (It's stated in my question).

What I want know is how can I do it WITHOUT having to add the .res file to the project. With Delphi I can put {$R file.res} in the component's source code, then I don't need to worry about the resource files and they CAN have both icons and images used by the component.

Is there any way to do something equivalent with C++Builder?
Not as far as I know. C++ always just includes the .RES files into the project. The DCR file is really only used to contain icons for component palette entries. The component does not need the icon when compiled into the application so it makes sense to separate them.

Raymond.
Avatar of edy081298

ASKER

You are wrong, Builder does NOT include the .RES file into the project unless you explicity add it (i'm looking for a way to avoid having to do it).

I've stored an image used by the component into a .RES file. The project compiles ok, but it can't find the resource when executed.

I'm sorry, I wasn't clear. I didn't mean that Builder does it automatically but that it is the way you do it.

What is so bad about including a res file?

Raymond.

Nothing bad, but I'm looking for a way to avoid it. When you use any standard component, you don't have to worry about including any .res file.

Moreover, if you use a Delphi component that uses resources into your C++Builder project, you don't have to add the .res file (Delphi components can use a $R directive, and C++Builder recognizes it).

Thanks for your interest, anyway.
I think you are trying to do something that cannot be done (unless you code your component in Object Pasca)l.

Cheers,

Raymond.
ASKER CERTIFIED SOLUTION
Avatar of hlava
hlava

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great! It works!

It's just what I was looking for!