Compartir a través de


Drag-and-Drop: Implementation Details

The following procedure describes how to implement drag-and-drop functionality in your snap-in. Be aware that only single-selection drag-and-drop operations are discussed in this topic. Multiselection drag-and-drop operations are implemented in essentially the same way as described in this topic. For more information, see Multiselection.

To implement single-selection drag-and-drop operations

  1. Enable the delete, copy, and paste standard verbs. Be aware that MMC automatically enables the cut verb when the delete and copy verbs are enabled (as long as the snap-in has not explicitly disabled the cut verb). The source scope or result item (henceforth the "source item") enables the delete and copy verbs (and therefore also the cut verb), and the destination scope or result item (henceforth the "destination item") should enable the paste verb. For more information, see Enabling MMC Standard Verbs.

  2. Handle the MMCN_QUERY_PASTE, MMCN_PASTE, and MMCN_CUTORMOVE notifications. All notifications are sent to the snap-in IComponent::Notify implementation. The following Steps discuss which snap-in (the source or the destination) must handle which notification.

  3. In the destination snap-in, handle the MMCN_QUERY_PASTE and MMCN_PASTE notifications.

    • MMC sends the MMCN_QUERY_PASTE notification if there is a data object available to paste. The destination snap-in should examine the data object and return S_OK if the object can be pasted or S_FALSE if the object cannot be pasted. If the data object can be pasted, MMC enables the paste verb for the destination item.
    • The MMCN_PASTE notification is sent when the user attempts to paste the source item in the destination item. After a successful paste, for delete and paste operations, the destination snap-in must specify a data object for the successfully pasted scope or result item in the param parameter (sent through MMCN_PASTE). This data object is forwarded to the source snap-in through the MMCN_CUTORMOVE notification.
  4. In the source snap-in, handle the MMCN_CUTORMOVE notification. MMC sends this notification after a successful paste in a cut/copy operation. The arg parameter passed through the notification contains the data object for the cut source item.

    Be aware that MMC does not delete a source item that has been cut by the user. If the user cuts a result item from a result pane, and the result pane is still visible after the cut, the snap-in should call IResultData::DeleteItem to remove the cut item. For a cut scope item, the snap-in should call the IConsoleNameSpace2::DeleteItem method to delete the scope item from the scope pane.

MMCN_QUERY_PASTE

MMCN_PASTE

MMCN_CUTORMOVE

Enabling MMC Standard Verbs