OLEDragOver Event

       

Occurs when one component is dragged over another.

Syntax

Private Sub object_OLEDragOver(data As DataObject, effect As Long, button As Integer, shift As Integer, x As Single, y As Single, state As Integer)

The OLEDragOver event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
data A DataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here.
effect A long integer initially set by the source object identifying all effects it supports. This parameter must be correctly set by the target component during this event. The value of effect is determined by logically Or'ing together all active effects (as listed in Settings). The target component should check these effects and other parameters to determine which actions are appropriate for it, and then set this parameter to one of the allowable effects (as specified by the source) to specify which actions will be performed if the user drops the selection on the component. The possible values are listed in Settings.
button An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed.
shift An integer which acts as a bit field corresponding to the state of the shift, ctrl, and alt keys when they are depressed. The shift key is bit 0, the ctrl key is bit 1, and the alt key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the ctrl and alt keys are depressed, the value of shift would be 6.
x,y A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target form or control. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.
state An integer that corresponds to the transition state of the control being dragged in relation to a target form or control. The possible values are listed in Settings.

Settings

The settings for effect are:

Constant Value Description
vbDropEffectNone 0 Drop target cannot accept the data.
vbDropEffectCopy 1 Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
vbDropEffectMove 2 Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
vbDropEffectScroll -2147483648

(&H80000000)

Scrolling is occurring or about to occur in the target component. This value is used in conjunction with the other values. Note   Use only if you are performing your own scrolling in the target component.

The settings for state are:

Constant Value Description
vbEnter 0 Source component is being dragged within the range of a target.
vbLeave 1 Source component is being dragged out of the range of a target.
vbOver 2 Source component has moved from one position in the target to another.

Remarks

Note   If the state parameter is vbLeave, indicating that the mouse pointer has left the target, then the x and y parameters will contain zeros.

The source component should always mask values from the effect parameter to ensure compatibility with future implementations of ActiveX components. Presently, only three of the 32 bits in the effect parameter are used. In future versions of Visual Basic, however, these other bits may be used. Therefore, as a precaution against future problems, drag sources and drop targets should mask these values appropriately before performing any comparisons.

For example, a source component should not compare an effect against, say, vbDropEffectCopy, such as in this manner:

If Effect = vbDropEffectCopy...

Instead, the source component should mask for the value or values being sought, such as this:

If Effect And vbDropEffectCopy = vbDropEffectCopy...

-or-

If (Effect And vbDropEffectCopy)...

This allows for the definition of new drop effects in future versions of Visual Basic while preserving backwards compatibility with your existing code.

Most components support manual OLE drag and drop events, and some support automatic OLE drag and drop events.