Solved

C++Builder - Component resource images

Posted on 1998-11-08
9
470 Views
Last Modified: 2010-04-02
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?
0
Comment
Question by:edy081298
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1177261
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.
0
 

Expert Comment

by:Edy
ID: 1177262
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?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1177263
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:edy081298
ID: 1177264
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.

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1177265
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.
0
 

Author Comment

by:edy081298
ID: 1177266

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.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1177267
I think you are trying to do something that cannot be done (unless you code your component in Object Pasca)l.

Cheers,

Raymond.
0
 

Accepted Solution

by:
hlava earned 100 total points
ID: 1177268
you can include RES file by this

#pragma resource "resspe.RES"

type that to .cpp file(I work in Borlan C++ Builder 3 profesional)

and then use name if icon or what you want
0
 

Author Comment

by:edy081298
ID: 1177269
Great! It works!

It's just what I was looking for!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question