OLEDragOver, OLEDragDrop
As their names suggest, these two events fire when data is dragged over an object or dropped onto an object, using OLE drag and drop. They give you a chance to respond programmatically to the drag or the drop.
Usage |
PROCEDURE oObject.OLEDragOver LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord, nState PROCEDURE oObject.OLEDragDrop LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord |
Parameter |
Value |
Meaning |
oDataObject |
Object |
A reference to a DataObject containing the data being dragged and information about it. |
nEffect (all applicable values are added together) |
0 |
This target won't accept this drop. |
1 |
The drop results in a copy. |
|
2 |
The drop results in a move. |
|
4 |
The drop copies the dropped data into the target and creates a link between the original source and the target. Because of VFP's caching of resources, this isn't useful for drop targets in VFP. |
|
nButton (all applicable values are added together) |
1 |
The left button was used for the drag. |
2 |
The right button was used for the drag. |
|
4 |
The middle button was used for the drag. |
|
nShift (all applicable values are added together) |
1 |
The Shift key was held down. |
2 |
The Ctrl key was held down. |
|
4 |
The Alt key was held down. |
|
nXCoord, nYCoord |
Numeric |
The mouse position in pixels, relative to the form, when the event fired. |
nState |
0 |
The mouse is entering the object. |
1 |
The mouse is leaving the object. |
|
2 |
The mouse is inside the object. |
Both nButton and nShift are unreliable when nState is 1; that is, when the mouse is leaving the object. Sometimes they contain the right value, but often they contain 0. |
Some ActiveX controls don't fire these events, while others do. We can't blame this on the VFP team, of course, since they didn't write these controls. Bottom line here is that you need to test whether the control you're using pays attention. The simplest way to do so is to put WAIT WINDOW PROGRAM() NOWAIT in each of the relevant events on a test form and run it. We'd rather recommend DEBUGOUT, but we haven't found it to be reliable even in the controls that do fire these events. Sometimes we see a WAIT WINDOW when a DEBUGOUT in the same method produces no results. Frankly, we think the problem is with the controls, not with VFP, because some controls handle DEBUGOUT just fine. |
Example |
* You might put this code in a form's DragOver event * to allow it to accept data passed from one of its controls IF oDataObject.GetFormat(1) This.OleDropHasData = 1 This.OLEDropEffects = 1 ENDIF * Suppose I want a drop into an edit box to copy rather than * move, despite the default. This code could go in OLEDragDrop nEffect = 1 && reset nEffect so OLECompleteDrag knows the score This.Value = oDataObject.GetData(1) && copy the data NODEFAULT && prevent the default behavior |
See Also |
DataObject, GetData, GetFormat, NoDefault, OLE drag and drop, OLECompleteDrag, OLEDrag, OLEDropEffects, OLEDropHasData, OLEDropMode, OLEGiveFeedback, OLEStartDrag |