Home   Index   About
Ultimate Pack


Custom Search
DoDragDrop

Carries out an OLE drag and drop operation.

HRESULT DoDragDrop(

IDataObject * pDataObject,
//Data object being dragged
IDropSource * pDropSource,
//Instance of IDropSource for source application
DWORD dwOKEffect,
//Specifies the effects allowed by the source
DWORD * pdwEffect
//Points to effects of the OLE drag and drop on the source
);

Parameters

pDataObject

Points to an instance of the IDataObject interface, which provides the data being dragged.

pDropSource

Points to an instance of the IDropSource interface, which is used to communicate with the source during the drag operation.

dwOKEffect

Specifies the effects the source allows in the OLE drag and drop operation. Most significant is whether it permits a move. The dwOKEffect and pdwEffect parameters obtain values from the DROPEFFECT enumeration. For a list of values, see DROPEFFECT.

pdwEffect

Points to a value that indicates how the OLE drag and drop operation affected the source data. The pdwEffect parameter is set only if the operation is not canceled.

Return Values

DRAGDROP_S_DROP

Indicates the OLE drag and drop operation was successful.

DRAGDROP_S_CANCEL

Indicates the OLE drag and drop operation was canceled.

E_OUTOFMEMORY

Out of memory.

E_UNSPEC

Indicates an unexpected error occurred.

Comments

If you are developing an application that can act as a data source for an OLE drag and drop operation, you must call DoDragDrop when you detect that the user has started an OLE drag and drop operation.

The DoDragDrop function enters a loop in which it calls various methods in the IDropSource and IDropTarget interfaces.

  1. The DoDragDrop function determines the window under the current cursor location. It then checks to see if this window is a valid drop target.

  2. If the window is a valid drop target, DoDragDrop calls IDropTarget::DragEnter. This method returns an effect code indicating what would happen if the drop actually occurred. For a list of valid drop effects, see the DROPEFFECT enumeration.

  3. DoDragDrop calls IDropSource::GiveFeedback with the effect code so that the drop source interface can provide appropriate visual feedback to the user. The pDropSource pointer passed into DoDragDrop specifies the appropriate IDropSource interface.

  4. DoDragDrop tracks mouse cursor movements and changes in the keyboard or mouse button state.

  1. If there is a change in the keyboard or mouse button state, DoDragDrop calls IDropSource::QueryContinueDrag and determines whether to continue the drag, to drop the data, or to cancel the operation based on the return value.

    • If the return value is S_OK, DoDragDrop first calls IDropTarget::DragOver to continue the operation. This method returns a new effect value and DoDragDrop then calls IDropSource::GiveFeedback with the new effect so appropriate visual feedback can be set. For a list of valid drop effects, see the DROPEFFECT enumeration. IDropTarget::DragOver and IDropSource::GiveFeedback are paired so that as the mouse moves across the drop target, the user is given the most up-to-date feedback on the mouse's position.

    • If the return value is DRAGDROP_S_DROP, DoDragDrop calls IDropTarget::Drop. The DoDragDrop function returns the last effect code to the source, so the source application can perform the appropriate operation on the source data, for example, cut the data if the operation was a move.

    • If the return value is DRAGDROP_S_CANCEL, the DoDragDrop function calls IDropTarget::DragLeave.

See Also

IDropSource::GiveFeedback


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun