Extending Toolbars and Toolbar Buttons for Snap-Ins

[This is preliminary documentation and subject to change.]

Toolbars are among the most-frequently included features in today's applications and the Microsoft Management Console makes taking advantage of them rather simple. Your snap-in can either extend the toolbars made available by the console or it can provide its own. There are several interfaces related to this feature, beginning with IControlbar. This interface allows for creating and manipulating a control bar to hold toolbars and other controls. This interface's methods includes Create, which is used to create and return the control requested. At this time, this can be either a toolbar or a combo box bar. The other IControlbar methods are Attach, which associates a control with the control bar, and Detach, which breaks that association. You should also use these methods to use display or hide the toolbar.

The IExtendControlbar interface allows an extension snap-in to add toolbars by using a callback interface, and has two methods. The first is SetControlBar, which gets a pointer to the IControlbar interface implemented by the console. The second method, ControlbarNotify, is the mechanism that allows the snap-in to respond to user actions such as mouse-button clicks. When the user causes an event, the node manager sends a notification message to the snap-in. All notifications applicable to MMC are listed alphabetically in MMC Notifications.

IToolbar is implemented by the console and it allows your snap-in to perform a variety of actions related to toolbars, including creating them, adding items to them, extending them, and displaying them. AddBitmap allows you to add an image to the toolbar, and AddButtons provides a way to add an array of buttons to the toolbar. To add a single button, you can use InsertButton and to remove one, you can use DeleteButton. Finally, you can get an attribute of a button by using GetButtonState and set an attribute with SetButtonState.

The last interface you have to consider when working with toolbars is IConsoleVerb. The verbs are listed in the MMC_CONSOLE_VERB enumeration and include cut, copy, paste, print, and others you would expect to see. You can determine the state of a verb by using the GetVerbState method and you can set the state with SetVerbState.