Indicates whether a drop can be accepted, and, if so, the effect of the drop.
HRESULT DragEnter(
IDataObject * pDataObject,
//Pointer to the interface of the source data
// object
DWORD grfKeyState, //Current state of keyboard modifier keys
POINTL pt, //Pointer to the current cursor coordinates
DWORD * pdwEffect //Pointer to the effect of the drag-and-drop
// operation
);
This method supports the standard return values E_OUTOFMEMORY, E_INVALIDARG, and E_UNEXPECTED, as well as the following:
You do not call IDropTarget::DragEnter directly; instead the DoDragDrop function calls it to determine the effect of a drop the first time the user drags the mouse into the registered window of a drop target.
To implement IDropTarget::DragEnter, you must determine whether the target can use the data in the source data object by checking three things:
To check the format and medium, use the IDataObject pointer passed in the pDataObject parameter to call IDataObject::EnumFormatEtc so you can enumerate the FORMATETC structures the source data object supports. Then call IDataObject::QueryGetData to determine whether the data object can render the data on the target by examining the formats and medium specified for the data object.
On entry to IDropTarget::DragEnter, the pdwEffect parameter is set to the effects given to the pdwOkEffect parameter of the DoDragDrop function. The IDropTarget::DragEnter method must choose one of these effects or disable the drop.
The following modifier keys affect the result of the drop:
Key Combination | User-Visible Feedback | Drop Effect |
---|---|---|
ctrl + shift | = | DROPEFFECT_LINK |
ctrl | + | DROPEFFECT_COPY |
No keys or shift | None | DROPEFFECT_MOVE |
On return, the method must write the effect, one of the members of the DROPEFFECT enumeration, to the pdwEffect parameter. DoDragDrop then takes this parameter and writes it to its pdwEffect parameter. You communicate the effect of the drop back to the source through DoDragDrop in the pdwEffect parameter. The DoDragDrop function then calls IDropSource::GiveFeedback so that the source application can display the appropriate visual feedback to the user through the target window.
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in oleidl.h.
DoDragDrop, IDropSource, IDropTarget, RegisterDragDrop, RevokeDragDrop