Linking binary Files

Hello,
is there anyway in Delphi 4 Standard, to link the following Files direclty into the EXE and then use it at run-time ?

- WAVES (using MediaPlayer)
- ICONS (I didn't see an 'import' menu or something in     ImageEdit)
- FONTS (A TTF-Link would be great, to use for different elements such as StaticText, Label, Edit, RichEdit)

Thanx, Roger ;)
LVL 2
omsecAsked:
Who is Participating?
 
BoRiSConnect With a Mentor Commented:
omsec

here is a quick example of an rc file...

1) Create a wave file called 'click.wav' & 'error.wav' & 'next.wav'
in the project's directory.

2) Create a text file called 'sound.rc'
in the project's directory.

3) Add the following line to the file 'sound.rc':
CLICK WAVE click.wav
ERROR WAVE error.wav
NEXT WAVE next.wav

4) At a dos prompt, go to your project directory
and compile the .rc file using the Borland Resource
compiler (brcc32.exe) by typing the path to brcc32.exe
and giving 'sound.rc' as a parameter.

Then in your project call this...

//remeber to add mmsystem to your uses clause...
 uses
  Windows, Forms, ..., mmsystem;

//then add the res file

implementation

 {$R sound.res}

procedure TForm1.Button1Click(Sender: TObject);
begin
 PlaySound('CLICK', hInstance, SND_RESOURCE or SND_SYNC);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 PlaySound('ERROR', hInstance, SND_RESOURCE or SND_SYNC);
end;

and so on...

to add icon's etc just change the wave stuff i gave you...

//example add to .rc file...

NEW ICON 'place.ico'

in code add...

procedure TForm1.Button3Click(Sender: TObject);
begin
 Image1.Picture.Icon.LoadFromResource(hInstance, 'place');
end;

Hope this Helps

Later
BoRiS
0
 
BoRiSCommented:
omsec

As I understand it you can put them into a resource file and compile the resource into the exe so the files will be available a runtime

You can link all this files and then use brcc32.exe under the bin directory to build a 16 or 32 bit res file and included it in your program...

{$R myres.res}

Later
BoRiS
0
 
omsecAuthor Commented:
hmh, this looks like a scripting language or something. Do you have experience with it ? WOuld be very usefull to see an example. if it's that hard, i can increase points...

btw, i this if from Delphi-FAQ at borland's,
i didnt get it to work :

Create a resource file containing the icons you wish to use, then
use the Windows API function LoadIcon(),

Example:

{$R MYRES.RES}

procedure TForm1.Button1Click(Sender: TObject);
var
  h : hIcon;
begin
  h := LoadIcon(hInstance, 'ICON_1');
  Application.Icon.Handle := h;
  InvalidateRect(Application.Handle, nil, true);
end;

i tried different ways
ICON_1, Icon1, Contentents\Icon\Icon1 etc.

thanx
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
BoRiSCommented:
omsec

Have you created the res file with ImageEditor and added an icon called ICON_1 and saved it under your projects directory and called the res file myres.res

The directive

{$R ....} will include the res file specified...

The example from Inprise works fine if all the above is done.

Later
BoRiS
0
 
freterCommented:
omsec:
you can out virtually anything into a resource. there are, of course special resource trees in an executable for the most common data types like icons, stringlists, accellerators and so on. if you are lookng for an easy way of producing resources, go and get Merlin (website: http://www.boots.com/merlin, also on the superpage: http://sunsite.icm.edu.pl/delphi/ftp/d20share/merlin.zip). this is a set of experts (which for themselves are quite helpful) and a resource editor that allows you to put anything you like into a resource. it also will generate code for loading a resource into delphi.
regds, freter
0
 
omsecAuthor Commented:
hm, a quick refernce, an example of an RC-File or a brcc32 HLP would be enough i think, since Delphi 4 standard doesnt come with a such helpfile
0
 
erajojCommented:
Hi,
install the RXLib (http://rx.demo.ru/).
In it there is a great resource manager.
Very, very simple to use!

/// John
0
 
freterCommented:
omsec: give merlin a try. you won't have to struggle with .rc files if you use merlin, since you'll define verything within a gui!
http://www.boots.com/merlin
http://sunsite.icm.edu.pl/delphi/ftp/d20share/merlin.zip

rgds, freter
0
 
omsecAuthor Commented:
i still dunno how to link TTF-Fonts
0
 
omsecAuthor Commented:
i didnt found the implementation of PlaySound - Procedure either.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.