Ô RES Ô
 © 29/12/98 Jean Claude Meier
 

Under Windows and with Delphi it's very easy to put the main resources (BMP and WMF pictures, icons) directly in the .EXE file.

But we can also put a lot of other things : cursors, sounds, messages and even fonts !

We must, like in most high level languages, create a resources file (.RES).

Why :

- best use of memory (load and unload of resources if necessary)
- compacity (less files)
- security (less risk of damage or loss of files)
- more rapidity to load ?

and perhaps above all the possibility with an utilitary like Resource WorkShop to have access to these resources without having the source of the program (to translate a soft for different countries for example)

It's not very difficult but the documentation, supplied on the subject with Delphi,  is  rather thin . I will try to explain with elements found here or there.

For each project ( PROJECT1.DPR) Delphi create a PROJECT1.RES (name_of_ project.res) in which it puts only the icon (?). We don't touch this one !

We must create a own .RES and give it a name different from the program's name (TEST here) to put all the things we want to incorporate in it (pictures, sounds, icons, strings, ...)

The method :

With an editor (Notepad or Delphi editor), we must create a text file  with  .RC as extension
 

Example : TEST.RC  in which w'll put : 2 sounds , 3 pictures, 2 cursors, 3 icons et 3 strings.
 
 

S1        WAV     Son1.Wav 
S2        WAV     Son2.Wav 
vache     BITMAP  vache.bmp 
perroquet BITMAP  perroq.bmp 
rat       BITMAP  rat.bmp 
baton     CURSOR  baton.cur 
seau      CURSOR  seau.cur 
I1        ICON    icone1.ico 
I2        ICON    icone2.ico 
I3        ICON    icone3.ico 
STRINGTABLE  DISCARDABLE 

1, "Bonjour" 
2, "Good morning" 
3, "Guten Morgen" 

 
 

It's important to follow  exactly this model and then to compile with BRCC32.EXE (supplied with Delphi, BRCC in Delphi 1)

Syntax : BRCC32 Test

Don't forget here to put all the resources in the current directory when compiling with  BRCC32.
 
If no error happens, we obtain a  TEST.RES file that we can incorporate in a project as shown below :
 

var 
  Form1: TForm1; 

Implementation 
{$R *.DFM} 

{$R Test.res}

 
 
After compiling the project by Delphi, the .RES will be incorporated int the .EXE
 

Note :
Cursors, icons, and even pictures can be created with IMAGEDIT (supplied with Delphi) wich can directly realise the .RES.  (but be sure to capitalize all ressources names !)

In the project w'll call these different resources with appropriate procedures as described in file Unit1.pas.
 
For a basic use it's easiest to put the pictures and strings directly in the .EXE but for a professional one it's the right way, I think.
 

See the program project1.dpr accompanying this text  that demonstrates the technic.

I hope this could help ...

I learned a lot by studying the variety of sources generously given by their authors to the Delphi community.
 

 

Let's put our  RESOURCES  together to progress !
 

If you are interested send me a mail :
 

j-c.meier@ac-nancy-metz.fr