Solved

Resource file

Posted on 1998-07-17
6
280 Views
Last Modified: 2010-04-04
Hey! Is Borlands Image Editor the only to make .res files?
With bitmaps it seems to be limited to 16 colors.
Even when creating I chose SuperVGA (256 colors) -
they get reduced to 16. Is this Delphi or the Image Editor
doing this? Or is it me somehow?
Does anyone know another way to build .res files?
What about putting .wav files in the res?
Thanx.
0
Comment
Question by:timbro
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358140
Hi timbro,
You can make the .res files by hand,
or you can use any other resource editor.
Zif.
0
 

Author Comment

by:timbro
ID: 1358141
I guess I just got used to using the Image Editor...urg
Since then I successfully compiled and ran a bitmap res
with BRC the that worked great!
The Image Editor must be screwing with the colors after all.

So let me redirect the question (for the points)

I'm still trying the wav thing.
I've compiled a res with the script:

WAVE RCDATA "a.wav"

and of course used a valid wav file (a.wav)
it seemed to compile fine.
I'm using this code but it doesnt work:

////////////////////////////////////////
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, StdCtrls, mmsystem;

type
  TForm1 = class(TForm)
    Image1: TImage;
        Button1: TButton;
        procedure FormCreate(Sender: TObject);
      
      end;

var
      Form1: TForm1;

implementation

{$R *.DFM}
{$R WAV.RES}

procedure TForm1.FormCreate(Sender: TObject);
begin
  PlaySound('WAVE', HInstance, SND_RESOURCE or SND_ASYNC);
end;

end.
////////////////////////////////////////////


I know of another way involving finding handles and loading
resources but this one line of code seemed simpler.

any thoughts?


0
 

Author Comment

by:timbro
ID: 1358142
does the wav file have to be converted to raw data first?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Accepted Solution

by:
bome earned 50 total points
ID: 1358143
1. create a .rc file. It is just an ordinary text file with one line, for example
1000 WAVE sound.wav

"1000" is the resource name(you can use any number, strings are also possible, but then you'd have to change the code below), WAVE the resource type and sound.wav the file (in the same directory).
Name this file "wave.rc".

2. compile this with "BRC32", it is in the bin directory of Delphi. I use bat files for compiling rc files, for example for you the bat file would contain:
"C:\borland\delphi 3\bin\brc32" -r wave.rc

Running the bat file will create "wave.res".

3. test the res file:
Create a new project. In the unit include the directive
{$R wave.res} , for example after the implementation directive.
Include "mmsystem" in the uses command.
Place a button on the form and put this as onClick handler:

if not PlaySound(PChar(1000), hInstance, SND_ASYNC or SND_NODEFAULT or SND_RESOURCE) then
  ShowMessage('Error');

There, obviously, again 1000 is the resource name.

Pressing the button will play the file, which is loaded from the resource.

4. Bitmaps
"bitmap.rc":
1000 Bitmap bitmap.bmp

(this will include the image file bitmap.bmp into the resource)

"bitmap.bat":
"C:\borland\delphi 3\bin\brc32" -r bitmap.rc

Running bitmap.bat will create bitmap.res.

Test project:
include the resource:
{$R bitmap.res}

Place a button and a TImage component on your form.
Button onClick:
Image1.Picture.Bitmap.LoadFromResourceID(hInstance,1000);

Pressing the button will load the bitmap from the resoure and show it in the TImage component.

5. more
You can place several lines in one .rc file. Like that you can compile several images, waves, etc. in your res file. They must all have (for each type) different names (numbers).

Hope that works - it does for me. Maybe some things are delphi 3 specific, but I don't think so.

Bome
0
 

Expert Comment

by:bome
ID: 1358144
Hehe, have worked on the answer while 2 new comments were appearing.
- Obviously the image editor screws the colors down to 16.
- Use just normal wave files with header and everything.
bome
0
 

Author Comment

by:timbro
ID: 1358145
Damn, that was a fast response! Wow
I tried your rc script and it works!
I was not aware of the 'WAVE' data type. and I overlooked the
PChar.  


Thanx for the great info!
-Tim
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Master Detail with TADODataset 4 96
problem when i try to pack my dll file with upx 9 63
Convert Jpg /PNG To GIF 5 102
Printing problem 2 72
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now