Adding the Property Page

A property page consists of a dialog resource, and class derived from IPropertyPagesImpl that is designed to manage this resource.

The IPropertyPagesImpl method supports a default implementation of the Activate and Apply methods. The Activate method is called by the Win32®-based Pipeline Editor when the property pages for a component are displayed. The Apply method is called when the user clicks the Apply button on the property pages dialog box.

Using the Visual C++ user interface to add a property page to the MinMaxShip project results in a default implementation of IPropertyPagesImpl.

To add a property page to MinMaxShip
  1. Start the ATL Object Wizard, click Controls, click Property Page, and then click Next.

  1. You again get the dialog box allowing you to type the name of the object. Call the object MinMaxPropPg and type that name in the Short Name edit box.

Notice that the Interface edit box appears dimmed. This is because a property page does not need a custom interface.

  1. Click the Strings tab to set the title of the property page. The title of the property page is the string that appears in the tab for that page. The Doc String is a description that a property frame could use to put in a status line or tool tip. The standard property frame currently does not use this string, but you can set it anyway. You are not going to generate a Helpfile at the moment, so delete the entry in that text box. Click OK, and the property page object will be created.

The following three files are created.

File Description
MinMaxPropPg.h Contains the C++ class CMinMaxPropPg, which defines the property page.
MinMaxPropPg.cpp Includes the MinMaxPropPg.h file, and implements the Apply and Activate functions.
MinMaxPropPg.rgs The registry script that registers the property page object.

The new property page is added to the object entry map in MinMaxShip.cpp. A reference to the MinMaxPropPg class is added to the MinMaxShip.idl file. The new registery script file, MinMaxPropPg.rgs is added to the project resource. A dialog box template is added to the project resource for the property page. The property strings you specified are added to the resource string table.

Your final step in creating the property page is to open the project’s resource file, display the dialog template for the property page (IDD_MINMAXPROPPG), and add the controls through which the user of the MinMaxShip component will modify the component’s properties.

When you are finished, the dialog template should look like this one.

The edit controls should be given the following resource identifiers, in this order:

IDC_PERCENTAGE, IDC_MINSHIPPING


© 1997-1998 Microsoft Corporation. All rights reserved.