BeforeDragOver Event

Applies To

CheckBox control, ComboBox control, CommandButton control, Frame control, Image control, Label control, ListBox control, MultiPage control, OptionButton control, ScrollBar control, SpinButton control, TabStrip control, TextBox control, ToggleButton control, UserForm object.

Description

Occurs when a drag-and-drop operation is in progress.

Syntax

For Frame

Private Sub object_BeforeDragOver( ByVal Cancel As MSForms.ReturnBoolean,
úctrl As Control, ByVal Data As DataObject, ByVal X As Single, ByVal Y As
úSingle, ByVal DragState As fmDragState, ByVal Effect As
úMSForms.ReturnEffect, ByVal Shift As fmShiftState)

For MultiPage

Private Sub object_BeforeDragOver( index As Long, ByVal Cancel As
úMSForms.ReturnBoolean, ctrl As Control, ByVal Data As DataObject,
úByVal X As Single, ByVal Y As Single, ByVal DragState As fmDragState,
úByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

For TabStrip

Private Sub object_BeforeDragOver( index As Long, ByVal Cancel As
úMSForms.ReturnBoolean, ByVal Data As DataObject, ByVal X As Single,
úByVal Y As Single, ByVal DragState As fmDragState, ByVal Effect As
úMSForms.ReturnEffect, ByVal Shift As fmShiftState)

For other controls

Private Sub object_BeforeDragOver( ByVal Cancel As MSForms.ReturnBoolean,
úByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal
úDragState As fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal
úShift As fmShiftState)

The BeforeDragOver event syntax has these parts:

Part

Description

object

Required. A valid object name.

index

Required. The index of the Page in a MultiPage that the drag-and-drop operation will affect.

Cancel

Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event.

ctrl

Required. The control being dragged over.

Data

Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject.

X, Y

Required. The horizontal and vertical coordinates of the control's position. Both coordinates are measured in points. X is measured from the left edge of the control; Y is measured from the top of the control..

DragState

Required. Transition state of the data being dragged.

Effect

Required. Operations supported by the drop source.

Shift

Required. Specifies the state of SHIFT, CTRL, and ALT.


Settings

The settings for DragState are:

Constant

Value

Description

fmDragStateEnter

0

Mouse pointer is within range of a target.

fmDragStateLeave

1

Mouse pointer is outside the range of a target.

fmDragStateOver

2

Mouse pointer is at a new position, but remains within range of the same target.


The settings for Effect are:

Constant

Value

Description

fmDropEffectNone

0

Does not copy or move the drop source to the drop target.

fmDropEffectCopy

1

Copies the drop source to the drop target.

fmDropEffectMove

2

Moves the drop source to the drop target.

fmDropEffectCopyOrMove

3

Copies or moves the drop source to the drop target.


The settings for Shift are:

Constant

Value

Description

fmShiftMask

1

SHIFT was pressed.

fmCtrlMask

2

CTRL was pressed.

fmAltMask

4

ALT was pressed.


Remarks

Use this event to monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. When a drag-and-drop operation is in progress, the system initiates this event when the user moves the mouse, or presses or releases the mouse buttons. The mouse pointer position determines the target object that receives this event. You can determine the state of the mouse pointer by examining the DragState argument.

When a control handles this event, you can use the Effect argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, the drop source supports a copy (fmDropEffectCopy), move (fmDropEffectMove), or cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectCopy, the drop source supports a copy or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectMove, the drop source supports a move or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectNone. the drop source supports a cancel operation.

Most controls do not support drag-and-drop while Cancel is False, which is the default setting. This means the control rejects attempts to drag or drop anything on the control, and the control does not initiate the BeforeDropOrPaste event. The TextBox and ComboBox controls are exceptions to this; these controls support drag-and-drop operations even when Cancel is False.

See Also

BeforeDropOrPaste event, DataObject object.