Solved

Include a resource

Posted on 2004-09-24
7
225 Views
Last Modified: 2013-11-18
Hi

I've written a small component and want to include some small graphic resources into the component dcu.  

Anyone know what the rc should look like?  I know that in an exe it is <resource name> RCDATA <resource to include> but this resource is for a component, not an exe.
0
Comment
Question by:foxjax
[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
7 Comments
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 100 total points
ID: 12143892
take a look at example below:

implementation

{$R esSpin.RES}

procedure TesSpin.SetGlyphFirst(Value: TBitmap);
begin
  if Value <> nil then
    FSpinFirst.Glyph := Value
  else
  begin
    FSpinFirst.Glyph.LoadFromResourceName(HInstance, 'SPINFIRST');
    FSpinFirst.NumGlyphs := 2;
    FSpinFirst.Invalidate;
  end;
end;
0
 

Author Comment

by:foxjax
ID: 12144496
Thanks esoftbg but i am looking for what way to write the rc file

ie: this is what i use in an rc file when i make a program that i want to include resources with - <resource name> RCDATA <resource to include>

but what do i use instead of RCDATA when i am including the resource inside the dcu of a component
0
 
LVL 2

Assisted Solution

by:php4delphi
php4delphi earned 100 total points
ID: 12145944
There is no any difference between including resource to the program or component. In first case the resource will be linked into executable, in case of component resource will be linked to the package (.bpl) and you will see it at design-time and to the application when you will add your component to it.
Ssoftbg provides your completely correct example how to do it.

Resources never linked to dcu directly, you have to provide *.res file together with your dcu
To make res file first you have to write .RC file.
The .RC file is simply a text file that lists resources. For most purposes (except defining dialogs for non-VCL apps), you don't need a resource editor.

The file is in this format:

RESOURCENAME  RESOURCETYPE  FILENAME
For example, to include a bitmap in the resource file:

MyBitmap  BITMAP   MyBitmap.bmp
To include a cursor:

MyCursor  CURSOR  MyCursor.cur
You use the same technique to include AVI, WAV and ICO files.

For other filetypes, you can use the type RC_DATA.

To use the resource script (.RC) file, you use Borland's Resource Compiler (BRCC.EXE with Delphi 1, BRCC32.EXE otherwise) which is located in the Delphi Bin directory. The syntax is:

BRCC32 MyRes.RC
This creates MyRes.RES. You then add the {$R MYRES.RES} to a unit in your application to have Delphi's linker include it, and use one of the Load... API calls (or Delphi's wrappers for some components) to use the resource at runtime.

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!

 
LVL 22

Assisted Solution

by:Ferruccio Accalai
Ferruccio Accalai earned 50 total points
ID: 12146143
Just a must, nothing to add to php4delphi that is right.

Add to your favourites this link,it's a very useful tutorial on creating resources
http://delphi.about.com/library/weekly/aa021301a.htm

F68 ;-)
0
 
LVL 3

Accepted Solution

by:
Sabre earned 250 total points
ID: 12147423
Just thought i'd add another point.

If you want to include resources inside a component, you can create a dcr file with image editor - Just select New\Component resource file.  Save it with the same name as the component and link it in as esoftbg has already shown you.
0
 

Author Comment

by:foxjax
ID: 12178196
I have split the points between all that provided an answer.

Thanks all
0
 

Author Comment

by:foxjax
ID: 12178209
points split and graded A.

I had forgot all about image editor - with that info and the info php4delphi gave i was able to find out what i needed.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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