Share via


How-To Use Different Views

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

Four types of views are available for snap-in developers to choose from. A developer can choose to create an instance of a view class that inherits from one of the following:

  1. MmcListView

  2. HtmlView

  3. FormView

  4. MessageView

Each of these views presents a set of built-in features. They allow the snap-in developer to focus on the logic of the management task while making use of the features to render the view.

In this Topic

Using the MMC List View

Using the Html View

Using the Form View

Using the Message View

Using the MMC List View

Often, a snap-in must show a list of objects to be managed. MMC addresses this by providing the capability to show an MMC list view in the results pane. It is similar to a list view common control and supports the following feature functionality:

  • Ability to insert, delete or modify columns.

  • Ability to insert, delete, enumerate or modify result nodes.

  • Selectable view modes, for example, report, list, icon, or small icon.

  • Configurable list view capabilities, behaviors, and visual styles.

  • Ability to sort items.

The MmcListView class supports the following different modes for displaying result nodes in the results pane:

  • List
    Items are displayed as title strings to the right of their small (16x16) icon representations. Sub-items and column headers are not displayed.

  • Large Icon
    Items are displayed as title strings under their large (32x32) icon representations. Sub-items and column headers are not displayed.

  • Small Icon
    Items are displayed as title strings under their small (16x16) icon representations. Sub-items and column headers are not displayed.

  • Report
    Items are displayed as title strings to the right of their small (16x16) icon representations and placed under the first column header on the left side of the results pane. Subsequent column headers are arranged from left to right and corresponding sub-items are placed beneath each main item.

The MmcListViewDescription class provides the information that can be used by MMC to create a list view when a scope node is selected. To show an MMC list view in the results pane, an MMC list view description must be added to the ViewDescriptions collection of a scope node. The type of the class is the ViewType parameter, which is used for creating the view description of the correct type when the scope node is selected, and the results pane is populated. Since MMC is a multi-document interface (MDI) application, for any given scope node there may be multiple results pane instances at a given time. MMC creates the appropriate view instance at run-time, based on the advertised types of views available for a scope node. Columns collection supports the addition of columns at initialization time. At initialization, column titles can be supplied and column visibility can be set. Once the list has been shown only title and width changes can be made in the column definitions. The MMC list view is populated by adding ResultNode instances. To show values in the columns defined for the MMC list view, you must enter values in the SubItemDisplayNames collection for each result node. These sub-values are mapped from each sub-display name to each additional column by position. For a detailed example of a snap-in that uses an MMC list view, see the sample <MMC 3.0 Samples>\SelectionListViewSample.

Using the Html View

In certain applications the snap-in may need to show a webpage to the user. One such example is a real time report from a website. To handle these cases, MMC supports an Html view type which shows the content at the given URL in the results pane.

To show an HtmlView in the results pane, a scope node must add an HtmlViewDescription to its ViewDescriptions collection. A snap-in developer can use the MMC-created Html view with the default Html view type or can optionally set the ViewType to the type of a class derived from HtmlView. The Html view description always uses the URL to be shown as a parameter, which is used to populate the results pane with the content at the URL. Note that the URL cannot be programmatically changed once the view is created, although the user can click any links in the webpage shown to navigate to other pages. For a detailed example of a snap-in that uses an Html view, see the sample <MMC 3.0 Samples>\HtmlViewSample.

Using the Form View

The FormView class provides a way to embed a WinForm form in the results pane. This view can be used when a scope node requires a custom view that is different from a list of managed objects. The form view allows complete control over the results pane. It still supports the actions pane and context menu features and can update MMC by using the SelectionData object. To show a form view in the results pane, a scope node must add a FormViewDescription to its ViewDescriptions collection. The form view description uses the class derived from FormView as its ViewType parameter. Even when the form view is radically different from a list view, the same context menus and actions pane items can be used. When the SelectionData object is updated, MMC is informed that a selection has been made, and it updates the context menus and actions pane in the same consistent fashion as the MmcListView class. The developer does not need to create a shortcut menu for the actions in the form view if MMC is allowed to show its native shortcut menu. Some examples of form views are: thumbnail graphics, graphs, tree views, drawings and complex grids. For a detailed example of a snap-in that uses a form view, see the sample <MMC 3.0 Samples>\SelectionFormViewSample.

Using the Message View

In certain cases the snap-in developer may want to show a single message very quickly to the user such as an error condition, an alert, or a quick status of the snap-in. MMC supports a MessageView type which shows a quick icon, title, and a message to the user.

To show a message view in the results pane, a scope node must add a MessageViewDescription to its ViewDescriptions collection. The developer can use the default message view type or optionally set the ViewType to the type of a class derived from MessageView. MMC can show the message when the scope node is subsequently selected, and the results pane gets populated. For a detailed example of a snap-in that uses a message view, see the sample <MMC 3.0 Samples>\MessageViewSample.

See Also

MmcListView
HtmlView
MessageView
FormView
How-To Create Snap-ins With Rich Features
MMC Code Directory