Export (0) Print
Expand All
Expand Minimize

TN023: Standard MFC Resources

Note   The following technical note has not been updated since it was first included in the online documentation. As a result, some procedures and topics might be out of date or incorrect. For the latest information, it is recommended that you search for the topic of interest in the online documentation index.

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 CLIPART:

  • 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

  1. Open your application's resource file in Visual C++.
  2. Open COMMON.RC, which contains all the binary clip-art resources. This may take some time because the COMMON.RC file is compiled.
  3. Press CTRL and drag to copy the resource or resources you want from COMMON.RC to your application's resource file.
  4. 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 dragging (move the resources). You can also avoid this by always responding with "No" when you are 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

  1. Open your application's resource file in Visual C++.
  2. 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).
  3. Open the appropriate standard resources files in MFC\INCLUDE (for example, MFC\INCLUDE\AFXPRINT.RC)
  4. Copy all of the resources from the standard .RC file to your application resource file.
  5. 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.
  6. 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.

See Also

Technical Notes by Number | Technical Notes by Category

Show:
© 2014 Microsoft