Here's how to compile the cursor and sound as a resource into an executable file, and how to use it.
The first step: Build an rc file.
For example: Zpg.rc, the contents are as follows:
Demhint WAVE D:\Zpg2000\Res\DemHint.wav
Printtype BITMAP D:\Zpg2000\Res\PrintType.bmp
Arrowdown BITMAP D:\Zpg2000\Res\ArrowDown.bmp
Arrowup BITMAP D:\Zpg2000\Res\ArrowUp.bmp
ZoomIn CURSOR D:\Zpg2000\Res\ZoomIn.cur
Zoomout CURSOR D:\Zpg2000\Res\ZoomOut.cur
One of the first behavior resource names, the second behavior resource type, and the third behavior is a filename that exists.
Step two: Compile this file.
>BRCC32 zpg.rc
BRCC32.exe in the/borland/c++ builder6/bin/directory,
Compiled into a resource file Zpg.res
Step three: Declare the use of resources in the program
Add the #pragma resource "*.DFM" statement to the cells in your program that you want to use these resources
#pragma resource "zpg.res"
Sometimes you need to add #pragma package (smart_init)
or add to the project Master CPP file
Useres ("Zpg.res");
How do you finally invoke this resource? See:
Call Bitmap:
Graphics::tbitmap *pbitmap=new Graphics::tbitmap;
Pbitmap->loadfromresourcename ((unsigned int) hinstance, "Printtype");
Play Sound:
PlaySound ("Demhint", Hinstance,snd_resource);
To change the cursor:
Screen->cursors[crzoomin]=loadcursor (hinstance, "zoomin");
Crzoomin is a custom cursor constant that is customarily a >0 number, whereas a system-defined general <0
Paintbox->cursor= (tcursor) crzoomin;
Application->processmessages (); Make sure the cursor changes immediately
Attention:
Resource files are only useful at design time, and when compiled, the resources are compiled into executables, so the program is distributed without having to carry resource files.