OLEDrag, OLEStartDrag, OLECompleteDrag
These methods all belong to the drag source of an OLE drag and drop. OLEDrag starts a drag and drop, while OLEStartDrag and OLECompleteDrag fire at the indicated times to let you take action.
Usage |
PROCEDURE OLEDrag LPARAMETERS lDetectDrag PROCEDURE OLEStartDrag LPARAMETERS oDataObject, nEffect PROCEDURE OLECompleteDrag LPARAMETERS nEffect |
Parameter |
Value |
Meaning |
lDetectDrag |
.F. |
Begin dragging as soon as OLEDrag is called. This choice makes it impossible to highlight some text in a control and drag only the highlighted text, but might be appropriate for non-textual controls. |
.T. |
The drag doesn't begin until either the mouse moves some distance or some time has passed after the OLEDrag call. We went hunting to figure out how to change the distance or the time, but couldn't find anything. (We expected they'd be somewhere in the Control Panel, but we couldn't turn them up.) A look in the Registry didn't turn up anything promising either, so perhaps these settings really are fixed. |
|
oDataObject |
Object |
An object reference to the data being dragged and to information about the data. |
nEffect (Applicable values are added together) |
0 |
For OLEStartDrag, the drag source doesn't allow any kind of dragging. For OLECompleteDrag, no drop was performed. |
1 |
For OLEStartDrag, the drag source allows its data to be copied. For OLECompleteDrag, data was copied to the drop target. |
|
2 |
For OLEStartDrag, the drag source allows its data to be moved. For OLECompleteDrag, data was moved to the drop target. |
|
4 |
For OLEStartDrag, the drag source allows its data to be linked. For OLECompleteDrag, data was linked to the drop target. |
Calling OLEDrag doesn't work for some ActiveX controls. What makes this worse is that some of them don't have an OLEDragMode property or the equivalent, which means there's no way to drag data out of them. |
Dragging data from a spinner can be tricky. It's really hard to highlight the data you mean to highlight, so it can appear that you're not getting the results you wanted. We think this is related to a bug involving the Alignment property for spinners. You can read about that one under Alignment. |
Example |
* Turn on dragging with instant gratification. You might do this * for an object where highlighting is irrelevant. This.OLEDrag(.f.) * Create a custom data format for OLE drag and drop. * This format is for dragging an Image object. When dropped, * it supplies the name of the picture it contains. * This code goes in the Image control's OLEStartDrag event: oDataObject.SetFormat("Picture") oDataObject.SetData(This.Picture,"Picture") * To retrieve the picture's name, put code like this in the * OLEDragDrop event of the target. In this case it's a form, * and the form's wallpaper is set to the specified picture. IF oDataObject.GetFormat("Picture") This.Picture = oDataObject.GetData("Picture") ENDIF |
See Also |
Alignment, DataObject, GetData, GetFormat, NoDefault, OLE drag and drop, OLEDragMode, OLEDragDrop, SetData, SetFormat |