TN023: Standard MFC Resources
This note describes the standard resources provided with and needed by the MFC library.
Standard Resources
MFC offers two categories of predefined resources that you can use in your application: clip-art resources and standard framework resources.
Clip-art resources are additional resources that the framework does not depend on, but which you might want to add to your application's user interface. The following clip-art resources are contained in the MFC General sample :
COMMON.RC: a single file of resources containing
A large collection of icons that represent a variety of business and data-processing tasks
Several common cursors (see also AFXRES.RC)
A toolbar bitmap containing several toolbar buttons
The bitmap and icon resources used by COMMDLG.DLL
INDICATE.RC: contains string resources for the status-bar key-state indicators, such as "CAP" for Caps Lock.
PROMPTS.RC: contains menu-prompt string resources for each of the predefined commands, such as "Create a new document" for ID_FILE_NEW.
COMMDLG.RC: an Visual C++ compatible .RC file containing the standard COMMDLG dialog templates.
Standard framework resources are resources with AFX-defined IDs that the framework depends on for internal implementations. You will rarely need to change these AFX-defined resources. If you do, you should follow the procedure outlined below.
The following framework resources are contained in the MFC\INCLUDE directory:
AFXRES.RC: common resources used by the framework
AFXPRINT.RC: resources specific to printing
AFXOLECL.RC: resources specific to OLE client applications
AFXOLESV.RC: resources specific to full OLE server applications
Using Clip-Art Resources
To use a clip-art binary resource:
Open your application's resource file in Visual C++.
Open COMMON.RC, this contains all the binary clip-art resources. This may take some time as the COMMON.RC file is compiled.
Press CTRL and drag to copy the resource(s) you want from COMMON.RC to your application's resource file.
If you want, rename the resource from a string name to a symbol.
To use other clip-art resources, the steps are as above except you open the appropriate .RC file instead of COMMON.RC. Renaming the resource ID is not needed since the clip-art resources will already be assigned the appropriate symbols for you.
Note Be careful not to unintentionally move resources out of COMMON.RC permanently. You can avoid this by CTRL-dragging (copy) rather than straight dragging (move the resources). You can also avoid this by always responding with "No" when you're asked whether you want to save the changes to COMMON.RC.
The .RC resource files have a special TEXTINCLUDE resource in them that will prevent you from accidentally saving on top of the standard .RC files.
Customizing Standard Framework Resources
Standard framework resources are usually #include'd in your application's .RC file. AppWizard will generate a .RC file that includes the appropriate standard framework resources depending on which AppWizard options you choose. You can review, add, or remove which resources are #include'd by using Visual C++'s "Set Includes..." command in the Resource menu of Visual C++ and looking at the "Compile-Time Directives" edit item. For example:
#include "afxres.rc"
#include "afxprint.rc"
The most common case of customizing standard framework resources is adding or removing additional includes for printing, OLE Client, and OLE Server support.
In some rare case you may wish to customize the contents of the standard framework resources for your particular application, not just add and remove the entire file.
To customize the contents of a standard resource file, please follow these steps:
Open your application's resource file in Visual C++.
Using the Resource Set Includes command, remove the #include for the standard .rc file you want to customize (for example, to customize the print-preview toolbar, remove the #include "afxprint.rc" line).
Open the appropriate standard resources files in MFC\INCLUDE (for example, MFC\INCLUDE\AFXPRINT.RC)
Copy all of the resources from the standard .rc file to your application resource file.
This is an all or none proposition. Either you #include all of the resources from the .RC file in MFC\INCLUDE or you have a (customized) copy of these resources in your application resource file.
Modify the copy of the standard resources in your application resource file.
Note Be especially careful not to modify the resources directly in the standard .RC files.