IDropTarget::DragEnter

Indicates whether or not a drop can be accepted and the drop's effect if accepted.

HRESULT DragEnter(

IDataObject * pDataObject,
//IDataObject interface for the source data
DWORD grfKeyState,
//Current state of keyboard modifier keys
POINTL pt,
//Current cursor coordinates
DWORD * pdwEffect
//Effect of the drag-and-drop operation
);

Parameters

pDataObject

[in] Points to the data object being transferred in the drag-and-drop operation. The data is represented in the IDataObject interface. If the drop occurs, this data object will be incorporated into the target.

grfKeyState

[in] Identifies the current state of the keyboard modifier keys on the keyboard. Valid values can be a combination of any of the flags MK_CONTROL, MK_SHIFT, MK_ALT, MK_BUTTON, MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON.

pt

[in] Points to the current cursor coordinates in the coordinate space of the drop target window.

pdwEffect

[in, out] Specifies the current effect flag. Valid values are from the DROPEFFECT enumeration.

Return Values

S_OK

The function completed its task successfully.

E_OUTOFMEMORY

Out of memory.

E_INVALIDARG

One or more arguments are invalid.

E_UNEXPECTED

An unexpected error occurred.

Comments

The DoDragDrop function calls this method the first time the user drags the mouse into the registered window of a drop target.

In the IDropTarget::DragEnter method, you must determine the effect of dropping the data on the target by examining the formats and medium specified for the data object along with the state of the modifier keys. 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

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.

On entry to IDropTarget::DragEnter, the pdwEffect parameter is set to the effects given to the DoDragDrop function. The IDropTarget::DragEnter method must choose one of these effects or disable the drop.

Upon return, pdwEffect is set to either DROPEFFECT_COPY to copy the dragged data to the target, DROPEFFECT_LINK to create a link to the source data, or DROPEFFECT_MOVE to allow the dragged data to be permanently moved from the source application to the target.

You may also wish to provide appropriate visual feedback in the target window.

See Also

DoDragDrop, IDropSource, IDropTarget, RegisterDragDrop, RevokeDragDrop

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database