PDA

View Full Version : Questions



Aeronautics
23-03-2003, 03:47 PM
I'm creating version 2 of bomberman and using DirectDraw for it.

1) I want to add some music and sounds, but without using TMediaPlayer, how do I do this?

2) How do I get an application icon in a API program (not the window icon, but the icon the executable itself has.

3) Is there free software that makes a setup application, excluding winzip (or powerarchiver) selfextractor or the installshield for delphi?

Xorcist
23-03-2003, 08:56 PM
1) You could attempt to use DirectSound, or another API.

2) You need to edit the application's resource file, or create a new one, such that there is an ICON resource called MAINICON which contains the icon data you wish to be the application's icon. Hope that helps.

3) Sure there are plenty, check out this (http://www.thefreecountry.com/programming/setup.shtml) site for a good listing of various free installers.

Darhazer
25-03-2003, 03:02 PM
2) You should only include {$R *.res} in your source code and you'll be able to choose Icon from the project options

1) You can use playsound() API function to play external wave or wave which is build in your resource file. Problem is that you cannot build-in wave into the resource file; it is possible to do this with VC++

3) Yes, there are many such installers. One is InnoSetup (I can't remember if it is free), you can also check out http://clickteam.com for theis installer. If you search the web (http://download.com is perfect) for Install maker you'll find many pretty freeware programs

Aeronautics
26-03-2003, 06:52 AM
Alright, thank you guys!

Alimonster
29-03-2003, 07:21 PM
1) You can use playsound() API function to play external wave or wave which is build in your resource file. Problem is that you cannot build-in wave into the resource file; it is possible to do this with VC++

It is possible to do this IIRC, but you have to manually write the resource file script (a little pain). Create a text file with a .rc extension ("myfile.rc"). Enter the following sort-of-stuff into it:

my_wave_name WAVE moo.wav
my_other_wave WAVE somefile.wav
yet_another WAVE thirdsound.wav

...and so on.

Add this to your project: Project->Add To Project menu, and select the wanted .rc. Once you've done this, Delphi will compile the resource script into a .res and will link it to your exe automatically (no need for a $R if you do it this way). I'd suggest creating a .rc file for sounds only, and doing everything else in the Image Editor tool and a $R. Makes life easier!

Also, when you're linking .res resources, remember that *.res means "a res file with the same filename as the current unit", not "any and every resource file". Just in case you use multiple .res files, that's all...

You can then play the stuff with sndPlaySound/PlaySound -- e.g.,

PlaySound('my_wave_name', HInstance, SND_ASYNC or SND_RESOURCE or SND_LOOP);

Where the first parameter is the same as one of the names in the .rc file.

You might also want to investigate FMod and/or BASS -- I'd assume they have loading-from-resouce functions, though of course, I haven't used them yet...

Darhazer
03-04-2003, 04:43 PM
Alimonster, it is possible to compile 24bit bitmaps into resource, not only 256 colored bitmaps?

Alimonster
03-04-2003, 05:38 PM
Yep. For some reason, the bitmap editor can't handle > 256 colour pictures (which seems a strange limitation, but never mind).

You can add bitmaps to the resource compiler script (.rc) in much the same way as sound files -- in this case, the relevant type is BITMAP. For example, adding a bitmap into the above "myfile.rc" example:

my_wave_name WAVE moo.wav
my_other_wave WAVE somefile.wav
yet_another WAVE thirdsound.wav
my_lovely_picture BITMAP somepic.bmp

You can load it up in the VCL using the tbitmap's LoadFromResourceName method:

var
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.LoadFromResourceName(HInstance, 'my_lovely_picture');

// use the bitmap now
finally
Bmp.Free;
end;
end;

For non-VCL stuff, you can use the LoadImage or LoadBitmap functions, I think.

You might also want to add the DISCARDABLE flag, which will let the things be unloaded from memory if there's little memory left, and reloaded later. Example:

my_lovely_picture BITMAP DISCARDABLE somepic.bmp

I don't know what effect that has, though, since it's been a long time since I ever ran low on memory!

M109uk
12-04-2003, 07:42 PM
It is possible to do this IIRC, but you have to manually write the resource file script (a little pain). Create a text file with a .rc extension ("myfile.rc"). Enter the following sort-of-stuff into it:

my_wave_name WAVE moo.wav
my_other_wave WAVE somefile.wav
yet_another WAVE thirdsound.wav

...and so on.



As an alternative to writing rc files, i found a great resource editor, free and with Delphi source code. i have'nt really used it much except for changing icons around so i don't know if it will work with wave files or anything, but could be worth a try :)

the URL is:
http://www.wilsonc.demon.co.uk/d7resourceexplorer.htm