Merging Resource Files

AppWizard creates a .RC file for the new MFC project, containing some valuable resources. But you don't want to abandon your old resources either, so you must consolidate the two files, using the new one as a base.

Copy individual resources from your old .RC file, resource by resource, into the new project's .RC file, as described below. First read the general procedure, then take a look at the specifics for SHOWDIB.

Þ To copy resources from one file to another in Visual C++

1. Open the new .RC file, then open the old .RC file in its original directory.

When you open an .RC file, Visual C++ (App Studio in versions before 2.0) compiles it and presents a window containing various categories of resources.

2. Position the two .RC file windows side by side in Visual C++.

3. Copy individual dialog, menu, icon, and other resources from the old file to the new.

Tip To copy a resource, hold down the CTRL key; then drag the resource from the old file and drop it onto the new file window. Without the CTRL key, you'll move the resource, not copy it.

Figure 5 shows two .RC windows open in Visual C++.

When you save the new file, the MFC project's RESOURCE.H file is updated with IDs for the added resources.

Note RESOURCE.H is a standard MFC file that contains ID definitions for commands, dialog boxes, and so on. AppWizard and ClassWizard do most of the work of updating this file for you. The documentation describes its use, including advanced options. The best way to examine the symbols defined in your MFC application in Visual C++ 2.0 is to use the Resource Symbols command. In earlier versions, use the Edit Symbols command in App Studio. See your C++ documentation.

For SHOWDIB, merging resource files involves copying one icon, one menu, and several dialogs:

In your application, handle other kinds of resources similarly. In some cases, you want your preexisting resource to replace the default version created by the wizard. Where there is no duplication, you simply want to copy your resources into the new project.