Share via


Understanding Custom Resource Templates

OverviewsHow Do IDetails

Feature Only in Professional and Enterprise Editions   Creating a Custom AppWizard is supported only in Visual C++ Professional and Enterprise Editions. For more information, see .

The MFC AppWizard obtains the building blocks for the code, resource, and project files it creates from special files called custom resource templates. There are two types of custom resource templates: text templates and binary templates. Text templates are used to create the source files for a project, and binary templates usually contain bitmaps for user-interface components, such as toolbars.

AppWizard always provides you with a copy of the CONFIRM.INF and NEWPROJ.INF templates and, if you use existing sequences of standard MFC AppWizard steps, AppWizard copies its own custom resource templates into your custom AppWizard project for you to use and/or modify. You can also create your own templates and add them to your custom AppWizard project.

Custom resource templates are resources of type “TEMPLATE”. You can see these if you double-click your project’s resource script file (.RC) in the Workspace window. All custom resource templates are in the folder called “TEMPLATE”. Because these are custom resources, they are treated as binary data. If you double-click a custom resource type in the Project Workspace window, the associated file opens in a binary editor. If you want to edit a custom resource, you must know the actual type it represents and choose that type from the Open As list in the Open dialog box.

To open a custom resource type in the appropriate editor

  1. On the File menu, click Open.

  2. Select the drive and directories where the template is stored.

  3. In the Files of type box, set the types of files to display.

    Files with the chosen extension are displayed in the File Name box.

    This box serves as a filter to display all files with a given extension. For example, selecting Image Files in the Files of Type box displays all files with *.BMP, *.DIB, *.ICO, and *.CUR extensions in the File name box.

  4. In the File Name box, select a filename.

  5. From the Open As list, select the type of file that describes the template you wish to open.

    The Auto type will correctly recognize custom resource template file extensions such as .BMP, .H, and .CPP and open an associated file in the correct editor. Select Text from the Open As list to edit custom resource templates that represent resource scripts (.RC files).

To create a custom resource template

  1. Copy the file you wish to import as a custom resource template to your project’s Template directory.

  2. On the Insert menu, click Resource.

  3. From the Resource type list, select the type of the custom resource template and click Import.

  4. In the Look in box, select your project’s Template directory.

  5. In the Files of type box, set the types of files to display.

    This box serves as a filter to display all files with a given extension. For example, selecting Icons in the Files of type box displays all files with *.ICO extension in the File Name box.

  6. In the File name box, select a file name.

  7. From the Open As list, select Custom and then click Import.

  8. From the Resource Type list, choose “Template”.

    The file is imported into your project as a custom resource type and opened in the binary data editor.

    The custom resource type is added to your project under your projects “Template” folder, which is available by selecting the ResourceView tab in the Project Workspace window. The custom resource template type is given an ID of IDR_TEMPLATE*, where * is a number that is unique within the “Template” folder. You can use the Properties command on the pop-up menu to change the ID. To activate the ID’s pop-up menu, place the mouse cursor on the new custom resource template’s ID in the “Template” window and click the right mouse button.

What do you want to know more about?