How to use resource files

Source: Internet
Author: User

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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.