How Do I Add Menu Items, Control Bar Buttons, and a Property Sheet to the Snap-In Object?

There are several user interface (UI) components of the MMC snap-in object that can be customized. Some of these areas, such as toolbar buttons and menu items, affect components of the MMC application. The final component is a standard property sheet that displays the properties, of the snap-in object, that can be customized by the user. By default, the MMC Snap-In wizard does not generate any custom UI elements. However, there are placeholders throughout the snap-in object code that indicate where your custom UI elements can go.

Adding Custom Context Menu Items

One area you can customize is the context menu for the items of the snap-in object. Four menu items are available for customization: Top, New, Task, and View. The Snap-In wizard creates a menu resource with placeholders for the four slots.

Because the menu resource is known by the snap-in object, add any custom menu items needed under the appropriate slot and they automatically appear in the context menu of any snap-in item. The snap-in item knows which menu resource to use because the data object contains the following declaration:

SNAPINMENUID(IDR_MMCSNAP_MENU)

The Platform SDK provides an interface (IExtendContextMenu) to customize the context menu of a snap-in item. In most cases, you don't need to call this interface directly, but if the snap-in is advanced, more information on this interface is available in the Platform SDK.

Adding Control Bar Buttons

If your snap-in object uses a custom toolbar, you can add any number of buttons to it once the toolbar resource has been created. You can then provide handlers for each button to handle custom tasks. For more information, see How Do I Add a Toolbar Resource to the Snap-In Object?.

The Platform SDK provides an interface (IExtendControlbar) to customize the control bar of a snap-in. In most cases, you don't need to call this interface directly, but if the snap-in is advanced, more information on this interface is available in the Platform SDK.

Adding a Property Sheet

Each snap-in item can display a standard property sheet, accessible from the context menu when the user right-clicks the mouse.

By default, the MMC Snap-In wizard does not provide the implementation for this functionality. However, if you select the IExtendPropertySheet check box, the wizard creates a default property page class (CSnapNamePage, derived from CSnapInPropertyPageImpl) and a dialog resource (IDD_SnapName) for the property sheet.

To complete this feature, add controls that allow the user to modify the properties of the snap-in item.

To add additional pages to the property sheet, you need a new property page class, a new dialog resource, and additional code in the CreatePropertyPages method of your data class. In this example, the new class is called CMMCSnapPage2 and the dialog resource is IDD_MMCSNAP2.

Once you have the necessary classes and resources, add them to the CreatePropertyPages method to create and add the new property page to the sheet. For example, the following code adds a new page (pPage2), implemented with the new CMMCSnapPage2 class, to the snap-in object:

CMMCSnapPage2* pPage2 = new CMMCSnapPage2(_T("MMCSnap2"));
lpProvider->AddPage(pPage2->Create());

The Platform SDK provides an interface (IExtendPropertySheet) to customize the property sheet of a snap-in. In most cases, you don't need to call this interface directly, but if the snap-in is advanced, more information on this interface is available in the Platform SDK.