Borland C Builder Resource File Editing 1 Establishing Now from Borland C Builder -> Tools-> Image Editor Image Editor-> file-> new-> resource will appear in the menu Select Resource Classification Bitmap icon If you select BitMap, select the color and size of the bitmap. If it is from an external bitmap, you should know that it will appear under which it will appear under the bitmap file name, and you can click the Draw status. On the board, the external bit is taken here, then save 2 in C Builder Project-> Add to Project ... Mounting Resource File 3 Using a. Graphics :: Tbitmap * Bitmap; // Low Color Bitmap = New Graphics: :. Tbitmap (); Bitmap-> Handle = LoadBitmap (int (hInstance), "bitmap1") // 256 colors b LoadFromResourceName (int Instance, const AnsiString ResName); LoadFromResourceID (int Instance, int ResID); columns such as: 1 Graphics :: TBitmap * Bitmap; Bitmap = new Graphics :: Tbitmap (); Bitmap-> LoadFromResourceName (int (hinstance), "picture1"); 2 Image1-> Picture-> Bitmap-> LoadFromResourceName (int (hInstance), "BitMap1"); note case INT (Hinstance) int (Hinstance) INT (Hinstance) manual operation Select text file Enter content Bitmap1 Bitmap "C: /Windows/bitmap1.bmp" compile BRCC32.EXE to resource files in BIN directory BRCC32 - 32 TestWave.rc => TestWave.RES In the unit file CPP # Pragma Resource "D: //cbuilder/picture.res" TFORM1 * FORM1; Note Test.rc is a pure Text file, you can use WordPad to build, but when the deployment, the file name is added to "Test.rc", otherwise it will become Wave.rc.txt this method can add the sound file to you .exe Middle: 1. Establish a plain text resource file such as Wave.rc, the content is as follows: id_wave Wave "c: /testwave.wav" 2. BCB In Project-> Add to Project Add Test.rc to your project (ie In your program; 3. In the program:
Code: #include "mmsystem.h" Plays ("id_wave", hinstance, snd_resource); Playsound () && rc // ----------------------- -------------------------------------------------- - void __fastcall tform1 :: fromfileclick (TOBJECT * Sender) {Plays ("mail.wav", null, snd_filename);} // -------------------- -------------------------------------------------- ----- void __fastcall TForm1 :: FromFileMemoryClick (TObject * Sender) {TFileStream * WaveFile = new TFileStream ( "mail.wav", fmOpenRead); BYTE * wavemem = new BYTE [WaveFile-> Size 1]; WaveFile- > Read (Wavemem, Wavefile-> Size); Plays (Wavemem, Null, SND_MEMORY); Delete [] Wavemem; delete Wavefile;} // ----------------- -------------------------------------------------- ------ Void __fastcall tform1 :: fromResourceClick (TOBJECT * Sender) {Playsound ("Mail", Hinstance, SND_RESOURCE);} // ---------------- -------------------------------------------------- ------- void __fastcall tform1 :: fromResourceMemoryClick (TOBJECT * Sender) // RES can participate Number One is the name, the parameter 2 is the type name is also the TestWave Wave "C: /TestWave.wav" in the RC can be WAV, WAV_DATA arbitrary {handle reshandle; Byte * Wavdata; reshandle = FindResource (Hinstance, "Mail" , "Wave"); reshandle = loadResource (Hinstance, reshandle); wavdata = (unsigned char *) LockResource (reshandle); Plays (Wavdata, Null, SND_MEMORY); FreeResource (reshandle);} How to read the text of the resource file Go to a variable? TResourceStream * RS = New TresourceStream ((int) Hinstance, "MyData", "TXT"); TSTRINGLIST * SS = New TSTRINGLIST; SS-> LoadFromstream (RS); Delete RS;