Export (0) Print
Expand All

How Do I Enumerate the Child Items of the Snap-In Object?

Visual Studio 6.0

How Do I Enumerate the Child Items of the Snap-In Object?

To properly display the contents of a snap-in object, you need to enumerate the child items of the object, if they exist. The best place for this modification is in the Notify method of the snap-in data class (in this discussion, CSnapNameData).

Note   The snap-in data class is derived from CSnapInItemImpl.

By default, the ATL Object Wizard creates a handler for this notification. In this handler, you need to modify the existing switch statement to handle the and notifications.

Handling the MMCN_EXPAND Notification

The notification is sent when the snap-in object folder needs to be expanded or contracted. In this case, you need only enumerate the scope pane items. This enumeration is done in the case statement for the MMCN_EXPAND notification.

To insert the scope pane items, first retrieve the interface for the snap-in object, and then call the method. The following code demonstrates retrieval of the necessary interfaces:

CComQIPtr<IConsoleNameSpace,
&IID_IConsoleNameSpace> spConsoleNameSpace(pConsole);
// TODO : Enumerate scope pane items with a user-defined function

Handling the MMCN_SHOW Notification

The notification is sent when an item is selected or de-selected for the first time. This enumeration is done in the case statement for the MMCN_SHOW notification. Unlike the MMCN_EXPAND notification, you must enumerate both the result pane items and scope pane items.

First, enumerate the scope items by retrieving the interface for the snap-in object, and then calling the method. After you have enumerated the scope pane items, do the same for the result pane items by retrieving the interface and making a call to .

CComQIPtr<IConsoleNameSpace,
&IID_IConsoleNameSpace> spConsoleNameSpace(pConsole);
// TODO : Enumerate scope pane items with a user-defined function
CComQIPtr<IResultData, &IID_IResultData> spResultData(pConsole);
// TODO : Enumerate the result pane items with a user-defined function
Show:
© 2014 Microsoft