Freigeben über


Using Custom Webpages

The result pane of an MMC console can host HTML pages that are located either locally on the computer with MMC or on an external Web server.

This section discusses how to start a custom webpage in a snap-in.

To start a custom webpage

  1. Implement a mechanism for storing the selected view type (for example, standard list view or Web view) and the user's view preference. This allows a standard list view or the Web view to be loaded when MMC calls IComponent::GetResultViewType to display the result pane for a particular scope item in your snap-in.

  2. Handle selection of the Web view in the IComponent::GetResultViewType method.

    For a custom view provided by a webpage, ppViewType should point to the address of a string that contains the URL for the page. The following string represents the URL for the Microsoft website and could be returned in the ppViewType parameter to display the website in the result view pane.

    www.microsoft.com
    
  3. Handle the MMCN_SHOW notification message sent to the snap-in's IComponent::Notify implementation. Also, consider the following:

    • During MMCN_SHOW, the snap-in should cache the cookie (of the scope item) passed in the call to IComponent::Notify in the lpDataObject argument. The snap-in needs the cookie to identify the correct scope item when MMC sends it an MMCN_SELECT or MMCN_DESELECTALL notification message with a special data object (DOBJ_CUSTOMOCX or DOBJ_CUSTOMWEB).

      For snap-ins that have a custom result pane (OCX or web), MMC sends the MMCN_SELECT or MMCN_DESELECTALL notification with a special data object when the result pane is selected or deselected. The only way for snap-ins to identify the corresponding scope item is to use the cookie cached during MMCN_SHOW.

      Be aware that, to make sure that the data object is DOBJ_CUSTOMWEB (for web views), the snap-in should check the data object using the IS_SPECIAL_DATAOBJECT macro before dereferencing it.

    • Upon deselection of the result pane with the web view, the arg parameter of MMCN_SHOW is set to FALSE, indicating that the view is going out of focus. At this time, the snap-in can do any necessary clean-up.

  4. If necessary, handle the MMCN_RESTORE_VIEW notification message. The notification is sent to the snap-in's IComponent::Notify method when the result pane for a scope item must be restored by the snap-in after the user has navigated the view history using the Back or Forward buttons.

    By handling the notification, the snap-in can find out what the view type and view options were the last time the result pane was displayed. This is particularly important if, for example, the IComponent associated with the corresponding scope item supports multiple view types. Say the result pane supports two view types: list view and web view. The default view type is list view. The user selects another scope item and then presses the Back button to return to the same item. The user expects the web view, but the snap-in's default behavior is to display the list view. By looking at the MMCN_RESTORE_VIEW notification, the snap-in can find out what the view type and the view options were the last time the result pane was displayed and perform the necessary Steps to return the result pane to its previous state.

  5. If the snap-in adds items to the Action menu when the web view is displayed in the result pane, MMC calls the IExtendContextMenu::AddMenuItems method of the corresponding IComponent implementation with a special data object for the web view. To make sure that the data object is DOBJ_CUSTOMWEB (for web views), the snap-in should check the data object using the IS_SPECIAL_DATAOBJECT macro before dereferencing it. The snap-in can then determine what is selected on the web view and add menu items accordingly.