Although an application can use various resources that behave independently of each other, these resources are grouped into a text file that has the .rc extension. You can create this file manually and fill out all necessary parts but it is advantageous to let Microsoft Visual C++ create it for you. To start creating the resources:
- On the main menu, you can click Project -> Add Resource...
- In the Solution Explorer, you can right-click the name of the project, position the mouse on Add, and click Resource...
Any of these actions would display the Add Resource dialog box. From this dialog box, you would select the type of resource you want and click New (or Import...). You will then be expected to design or customize the resources. Throughout our lessons, we will see various examples. After creating or designing a resource, you must save it. In most cases, you can try closing the resource. In this case, Microsoft Visual C++ would prompt you to save the resource. If you agree to do this (which you mostly should), Microsoft Visual Studio would create a new file with the extension .rc.
To make your resource recognizable to the other files of the program, you must also create a header file, usually called resource.h. This header file must provide a constant integer that identifies each resource and makes it available to any part that needs it. This also means that most, if not all, of your resources will be represented by an identifier.
Because resources are different entities, they are created one at a time. They can also be imported from existing files.
The Add Resource dialog box provides an extensive list of resources to accommodate almost any need. Still, if you do not see a resource you need and know you can use it, you can add it manually to the .rc file before executing the program.
- If the Resource View is not visible, on the main menu, click View -> Other Windows -> Resource View.
In the Reource View, right-click Exercise1 -> Add -> Resource... - In the Add Resource dialog box, click String Table
- Click New
- Under the Type column header, click IDS_STRING101 and edit it to display IDS_ANNOUNCE and press Enter
- To save, on the Standard toolbar, click the Save button
- Close that window by clicking the Close button
- In the Resource View, expand the Exercise1 node et notice the Exercise1.rc node
Comments
Post a Comment