OLEDragMode, OLEDropMode

These two properties determine whether, and in what way, a control plays OLE drag and drop.

Usage

nODragMode = oObject.OLEDragMode
oObject.OLEDragMode = nODragMode
nODropMode = oObject.OLEDropMode
oObject.OLEDropMode = nODropMode

Parameter

Value

Meaning

nODragMode

0

Default. Don't allow data from this object to be dragged.

1

Allow data from this object to be dragged.

nODropMode

0

Default. Don't allow data to be dropped on this object.

1

Allow data to be dropped on this object.

2

If data is dropped on this object, pass it to the object's container.


OLEDragMode is easy. You either turn it on or off. If it's on (1), you can drag from that object. If it's off (0), you can't. That's all. Well, almost all. If OLEDragMode is off, you can still start dragging an object manually by putting a call to OLEDrag in an appropriate event, usually MouseDown or MouseMove.OLEDropMode is a little more complex. Having it off (0) is simple. You can't drop on the object and, if you don't make something different happen, you see the "No drop" graphic over that object. On (1) isn't too complicated, either. You can drop on the object and various events fire when you do. The interesting one is "Pass to Container" (2). In this case, when you drop on an object, rather than respond to it itself, if the object's container has OLEDropMode set to either 1 or 2, the container receives the drop and can respond accordingly. What makes this interesting is that there's a good chance that the container doesn't automatically accept the kind of data you're dropping, so you have to go in and mess with data formats and the like before the container will accept the drop. But it's very cool when you get it working. You can both drag and drop from the same object by setting both of these properties to non-zero values.

An object can use either VFP's native drag or OLE drag, but not both. If you set DragMode to 1 (Automatic), the value of OLEDragMode is ignored, and the object uses native dragging. However, an object can accept both native drops and OLE drops. Microsoft advises not mixing the two modes in one application, and we tend to agree that it could get confusing for the operator.


Example

* You'll usually set these properties at design-time.
* But you might let a user decide whether to have drag 
* and drop enabled, based on an application setting.
* So you might have code in the object's Init.
This.OLEDragMode = oApp.lDragAndDrop

See Also

DragDrop, DragMode, GetData, GetFormat, OLE drag and drop, OLEDrag, OLEDragDrop, OLEDropEffects, OLEDropHasData


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .