Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsDragSourceMBS class.

WindowsDragSourceMBS.DoDragDrop(dataObject as WinDataObjectMBS, OKEffect as Integer, byref Effect as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Drag & Drop MBS Win Plugin 10.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Carries out an OLE drag and drop operation.

Parameters:

dataObject: The WinDataObjectMBS data object that contains the data being dragged.
OKEffects: Effects the source allows in the OLE drag-and-drop operation. Most significant is whether it permits a move. The OKEffect and Effect parameters obtain values from the DROPEFFECT* constants.
Effect: Pointer 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.

This function returns S_OK on success. Other possible values include the following.

Return codeDescription
DRAGDROP_S_DROPThe OLE drag-and-drop operation was successful.
DRAGDROP_S_CANCELThe OLE drag-and-drop operation was canceled.
E_UNSPECUnexpected error occurred.

Remarks

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 WindowsDragSourceMBS and WindowsDropTargetMBS interfaces. (For a successful drag-and-drop operation, the application acting as the data source must also implement WindowsDragSourceMBS, while the target application must implement WindowsDropTargetMBS.)

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

If the window is a valid drop target, DoDragDrop calls WindowsDropTargetMBS.DragEnter. This method supplies an effect code indicating what would happen if the drop actually occurred. For a list of valid drop effects, see the DROPEFFECT* constants.

DoDragDrop calls WindowsDragSourceMBS.GiveFeedback with the effect code so that the drop source interface can provide appropriate visual feedback to the user.

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

If the user moves out of a window, DoDragDrop calls WindowsDropTargetMBS.DragLeave.

If the mouse enters another window, DoDragDrop determines if that window is a valid drop target and then calls WindowsDropTargetMBS.DragEnter for that window.

If the mouse moves but stays within the same window, DoDragDrop calls WindowsDropTargetMBS.DragOver.

If there is a change in the keyboard or mouse button state, DoDragDrop calls WindowsDragSourceMBS.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 WindowsDropTargetMBS.DragOver to continue the operation. This method returns a new effect value and DoDragDrop then calls WindowsDragSourceMBS.GiveFeedback with the new effect so appropriate visual feedback can be set. For a list of valid drop effects, see the DROPEFFECT constants. WindowsDropTargetMBS.DragOver and WindowsDragSourceMBS.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 WindowsDropTargetMBS.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 WindowsDropTargetMBS.DragLeave.

Some examples using this method:

The items on this page are in the following plugins: MBS Win Plugin.


The biggest plugin in space...