End. Delphi resourcestring resource String constant (19:19:38) Delphi resourcestring resource String constant (19:19:38) // resourcestring resource String constant {string variables defined by the resourcestring command will be saved to the string table of the program resource. Interestingly, when you open the execution file in the resource editor, you will see the defined string in the program resource. This means that the string does not enter the compilation code, but is saved in a separate area of the execution file (exe file .}
ProcedureTform1.button1click (Sender: tobject ); Resourcestring // supports data of all character types Str1 = 'delphi '; Str2 = 'xe '; Begin Showmessage (str1 + str2 ); End; Delphi res access the AVI silent animation file in the resource file (19:19:39)
// Res access the AVI silent animation file in the resource file // Write the RC Script in Notepad Myavi_01 Avi "flickanimation. Avi"
// Save As avires. RC // Brcc32 compile avires. Res // Add resources {$ R avires. Res}
// Play the AVI code ProcedureTform1.button6click (Sender: tobject ); Begin Animate1.resname: = 'myavi _ 01'; // resource ID Animate1.active: = true; End; Delphi res access the BMP image in the resource file (19:19:40)
// Res access the BMP image in the resource file 1. Write the RC Script text and save it as BMP res. RC. BMP 1 bitmap "aaa.bmp" BMP 2 BMP Type "bbb.bmp"
2 brcc32 c: \ Users \ Administrator \ Desktop \ BMP res. RC // The brcc32.exe file is in the Delphi directory. Compile BMP. RC into a resource file of BMP. Res. 3. Cut the BMP. Res file to the Delphi project file.
4 introduce resources under {$ R *. DFM} {$ r bmp. Res}
// Call the BMP file in the resource file // Bitmap method (RC format: BMP 2 bitmap "BMP 02.bmp ") ProcedureTform1.button1click (Sender: tobject ); Begin Image1.picture. bitmap. loadfromresourcename (hinstance, 'bmp 1 '); End;
// BMP Type method (RC format: BMP 1 BMP Type "BMP 01.bmp ") ProcedureTform1.button2click (Sender: tobject ); VaR Resstream: tresourcestream; Begin Resstream: = tresourcestream. Create (hinstance, 'bmp 2', 'bmp type '); Image1.picture. bitmap. loadfromstream (resstream ); Resstream. Free; End; Delphi res access the cursor file in the resource file (19:19:41)
// Res access the cursor file in the resource file { Screen. cursors [] is a cursor array. With the cursor file, we can add the custom cursor to this attribute. Because the default cursor index value in the array is 0, So unless you want to replace the default cursor, it is best to set the custom cursor index value to 1. } Mycur1 cursor "repair. cur" Mycur2 cursor "attack. cur"
Save as cursorsres. RC Brcc32.exe compile cursorsres. Res Add Resource {$ R cursorsres. Res}
ProcedureTform1.button1click (Sender: tobject ); Begin Screen. cursors [1]: = loadcursor (hinstance, 'mycur1'); // resource ID Image1.cursor: = 1; // cursor of the image control End;
ProcedureTform1.button2click (Sender: tobject ); Begin Screen. cursors [2]: = loadcursor (hinstance, 'mycur2'); // resource ID Self. cursor: = 2; // cursor of the current form End; Delphi res access the icon file in the resource file (19:19:42)
// Res access the icon file in the resource file 1 create an RC file {make sure there is an icon file AAA. ico bbb. ICO on the desktop} Ico1 icon AAA. ICO Ico2 icon BBB. ICO Name Myres. RC 2. Compile the RC file into the res File Brcc32 c: \ Users \ Administrator \ Desktop \ Myres. RC The file Myres. Res is generated.
3. Add the resource file in {$ R *. DFM }. {$ R Myres. Res}
4. Call the icon file in res. ProcedureTform1.button1click (Sender: tobject ); Begin Application. Icon. Handle: = loadicon (hinstance, 'ico1 '); End;
ProcedureTform1.button3click (Sender: tobject ); Begin Application. icon: =Nil; End; Delphi res access the JPEG image in the resource file (19:19:43)
// Res access the JPEG image in the resource file 1. Write RC Script text
Jpg1 jpgtype "jpg01.jpg" Write RC Script text in notepad and save it as jpgres. RC
2 brcc32 c: \ Users \ Administrator \ Desktop \ jpgres. RC // The brcc32.exe file is in the Delphi directory. Compile jpgres. RC into a jpgres. Res resource file {The resource file must be placed in the same directory} 3. Cut the jpgres. Res file into the Delphi project file.
4 introduce resources under {$ R *. DFM} {$ R jpgres. Res} {When you have multiple resource files, add them in turn}
// Access the JPEG image in the resource file // An error occurred. UsesJPEG; ProcedureTform1.button1click (Sender: tobject ); VaR JPG: tsf-image; Resstream: tresourcestream; Begin JPG: = tsf-image. Create; Resstream: = tresourcestream. Create (hinstance, 'jpg1', 'jpgtype '); JPG. loadfromstream (resstream ); Image1.picture. Assign (JPG ); JPG. Free; Resstream. Free; End; Delphi res access the PNG Image in the resource file (19:19:43)
// Res access the PNG Image in the resource file 1. Write RC Script text
Imgauto1 PNG "C: \ Users \ Administrator \ Desktop \ Automatic 1.png" imgauto2 PNG "C: \ Users \ Administrator \ Desktop \ Automatic 2.png" imgmore1 PNG "C: \ Users \ Administrator \ Desktop \ more colors 1.png "imgmore2 PNG" C: \ Users \ Administrator \ Desktop \ more colors 2.png" Write RC Script text in notepad and save it as jpgres. RC
2 brcc32 c: \ Users \ Administrator \ Desktop \ pngres. RC // The brcc32.exe file is in the Delphi directory. Compile pngres. RC into a pngres. Res resource file {The resource file must be placed in the same directory} 3. Cut the pngres. Res file into the Delphi project file.
4 introduce resources under {$ R *. DFM} {$ R pngres. Res} {When you have multiple resource files, add them in turn}
// Access the PNG Image in the resource file
// Setimgpicture (img_auto1, 'imgauto2', 'png '); ProcedureSetimgpicture (image: timage; resname:String; Restype: pwidechar ); VaR PNG: tpngimage; Res: tresourcestream; Begin PNG: = tpngimage. Create; Res: = tresourcestream. Create (hinstance, resname, restype ); PNG. loadfromstream (RES ); Image. Picture. Assign (PNG ); PNG. Free; Res. Free; End; Some methods are invalid for this project-resources and Images Delphi res package WAV audio files into the program (19:19:44)
// Res package the WAV audio file into a program Stp1. create an RC file; {sound file of the identifier sound format} {Chinese name supported} Create a new notepad and input click wave "click.wav" to save this file as a *. RC file. Here I save it as sound. RC. Note: The audio and audio files click.wav and sound. RC must be in the same directory. Stp2. convert the RC file to the res file; Copy the brcc32.exe file in the Delphi directory to the C: \ Windows directory and start running: Enter cmd to open the command bar and enter brcc32 c: \ Users \ Administrator \ Desktop \ sound. RC. In this way, a sound. Res file is compiled.
Stp3.UsesMmsystem is introduced below; InImplementationEnter {$ R sound. Res} below}
Stp4. use the following code to play music Playsound ('click', 0, snd_asyncOrSnd_resource); // string of the pchar type
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.