Share via


IDropTarget (Compact 2013)

3/28/2014

This interface is used to allow drag-and-drop operations in an application. Its methods are used by any application that can be a target for drag-and-drop operations.

When to Implement

Implement this interface if you are developing an application that can act as a target for a drag-and-drop operation. The IDropTarget interface is associated with your application windows and is implemented on your window objects. Call the RegisterDragDrop function to register your window objects as drop targets.

Methods

The following table shows the methods for this interface. Like all COM interfaces, this interface inherits the methods for the IUnknown interface.

Method

Description

IDropTarget::DragEnter

Indicates whether a drop can be accepted, and, if so, the effect of the drop.

IDropTarget::DragLeave

Removes target feedback and releases the data object.

IDropTarget::DragOver

Provides target feedback to the user and communicates the drop's effect to the DoDragDrop function so it can communicate the effect of the drop back to the source.

IDropTarget::Drop

Incorporates the source data into the target window, removes target feedback, and releases the data object.

Obtaining a Pointer

Do not call the methods of IDropTarget directly. See Remarks for more information.

Remarks

An application that can be a target for drag-and-drop operations is responsible for the following:

  • Determining the effect of the drop on the target application.
  • Incorporating any valid data when the drop occurs.
  • Communicating target feedback to the source application so it can provide appropriate visual feedback, such as setting the cursor.
  • Implementing drag scrolling.
  • Registering and revoking its application windows as drop targets.

The IDropTarget interface contains methods that handle all these responsibilities except registering and revoking the application window as a drop target. For those tasks, you must call the RegisterDragDrop and the RevokeDragDrop functions.

Do not call the methods of IDropTarget directly. The DoDragDrop function calls the IDropTarget methods during the drag-and-drop operation. For example, DoDragDrop calls IDropTarget::DragEnter when it detects the mouse has moved over a window that is registered as a drag target. Once the mouse has entered a drag-target window, DoDragDrop calls IDropTarget::DragOver as the mouse moves through the window and calls IDropTarget::DragLeave if the mouse leaves the target window or if the user cancels or completes the drag-and-drop operation. DoDragDrop calls IDropTarget::Drop if the drop finally occurs.

Requirements

Header

shobjidl.h,
shobjidl.idl

Library

Developer Implemented

See Also

Reference

Shell Interfaces