Implement the IExtendPropertySheet2::CreatePropertyPages Method to Display Property Pages

This topic discusses how to implement Step 4 of the procedure, "To extend a primary snap-in property sheet", from the Microsoft Management Console (MMC) topic, Extending the Property Sheet of a Primary Snap-in.

In the previous topic, Filter Display of Property Pages Using the extid Attribute, each Applications snap-in property page used the extid attribute to determine when to display the property page. To display the property page use the IExtendPropertySheet2::CreatePropertyPages method.

To implement CreatePropertyPages, you must include the following steps:

  1. Define one or more property pages by filling the PROPSHEETPAGE structure for each of the property pages with information about the page. Be aware that the standard size for a property page in an MMC console is 252 dialog units horizontally and 218 dialog units vertically.
  2. Call the API function CreatePropertySheetPage to create a property sheet page for each PROPSHEETPAGE structure. The function returns a handle to the HPROPSHEETPAGE type that uniquely identifies the page.
  3. Use the pointer to the IPropertySheetCallback interface passed to the snap-in in the call to the CreatePropertyPages method to call the IPropertySheetCallback::AddPage method to add each property page to the MMC-provided property sheet.

Displaying a property page code example

The following code example, taken from the AppExt.cpp file, shows how to display a property page when the check for the extid property is successful. If the property page retrieves its title from a string resource, in this example, IDS_TAB_GENERAL, and displays an icon to the left of its title, in this example, IDI_ICON_GENERAL, set the optional PSP_USETITLE and PSP_USEICONID.

   if ( SUCCEEDED( hr ) )
   {
      if ( bAddPage )
      {
         PROPSHEETPAGE psp;
         HPROPSHEETPAGE hPage = NULL;

         psp.dwSize = sizeof(PROPSHEETPAGE);
         psp.dwFlags = PSP_DEFAULT | PSP_HASHELP; 
            // | PSP_USETITLE; // | PSP_USEICONID;
         psp.hInstance = g_hinst;
         psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
         psp.pfnDlgProc = DialogProc;
         psp.lParam = reinterpret_cast<LPARAM>(this);
         psp.pszTitle = NULL; // MAKEINTRESOURCE(IDS_TAB_GENERAL);
         psp.pszIcon = NULL; // MAKEINTRESOURCE(IDI_ICON_GENERAL);

         hPage = CreatePropertySheetPage(&amp;psp);

         _ASSERT(hPage);

         hr = lpProvider->AddPage(hPage);
      }
   }

To create more than one property page using the full code example

  1. Copy the AppExt.h and AppExt.cpp files and rename them to a different name, for example, AppExt_new.h and AppExt_new.cpp.
  2. Replace all instances of the class name CPropSheetExtension with a new class name such as CPropSheetExtension2 within the copied files, AppExt_new.h and AppExt_new.cpp.
  3. Add the new files to the existing code project in order for the new files to be compliled and linked into the DLL during the build operation.