Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBox.OLEDragDrop Event

An object is dropped on the control.

Syntax

VB.NETPrivate Sub object_OLEDragDrop(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.OLEDragDrop
VBPrivate Sub object_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
C#.NETvoid object_OLEDragDrop(object sender, EventArgumentType e);
VC++void OnOLEDragDropobject(struct IVDMDataObject** Data, long* Effect, short* Button, short* Shift, float* x, float* y);
CHRESULT OnOLEDragDropobject(struct IVDMDataObject** Data, long* Effect, short* Button, short* Shift, float* x, float* y);

object

A SftBox object.

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 variable set by the target component identifying the action that has been performed (if any), thus allowing the source to take appropriate action if the component was moved (such as the source deleting the data).

EffectValueDescription
vbDropEffectNone0Drop target cannot accept the data.
vbDropEffectCopy1Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
vbDropEffectMove2Drop results in data being moved from the drag source to the drop source. The drag source should remove the data from itself after the move.

Note: Only Visual Basic offers the predefined constants vbDropEffectNone, etc. When using other languages, the constants have to be defined explicitly by the application.

Button

Describes the button(s) that are pressed. The Button argument is a bit field with bits corresponding to the left button, right button and middle button. These bits correspond to the values shown below. The bits set indicate the button that caused the event.

ButtonValueDescription
constSftBoxLeftButton1The left mouse button was pressed.
constSftBoxRightButton2The middle mouse button was pressed.
constSftBoxMiddleButton4The right mouse button was pressed.

Shift

Describes the state of the SHIFT, CONTROL and ALT keys. A bit is set if the key is down. The Shift argument is a bit field with bits corresponding to the SHIFT, CONTROL and ALT keys. It indicates the state of these keys. Some, all, or none of the bits can be set, indicating which of the keys are pressed.

ShiftValueDescription
constSftBoxShiftMask1The SHIFT key is down.
constSftBoxCtrlMask2The CONTROL key is down.
constSftBoxAltMask4The ALT key is down.

xPos

The x coordinate of the mouse cursor. The units used depend on the container (Visual Basic, Visual C++, etc.) and the coordinate system used.

yPos

The y coordinate of the mouse cursor. The units used depend on the container (Visual Basic, Visual C++, etc.) and the coordinate system used.

Comments

The OLEDragDrop event occurs when an object is dropped on the control.

The OLEDragDrop event only occurs if the OLEDropMode property is set to OLEDropSftBoxManual.

The Items.DropIndex property can be used to determine which item is the drop target in the control. The Items.DropIndex property is automatically set to -1 on return from the application's OLEDragDrop event. The value of the Items.DropIndex property is determined by the TargetIndex parameter of the OLEDragOver event.

The source control should always mask values from the Effect parameter to insure compatibility with future implementations of OLE drag & drop. Presently, only three bits in the Effect parameter are used. In future versions other bits may be used. 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, for example, vbDropEffectCopy, such as:

If Effect = vbDropEffectCopy... 

Instead, the source component should mask the value or values being sought, as here:

If (Effect And vbDropEffectCopy) = vbDropEffectCopy... 

-or-

If (Effect And vbDropEffectCopy)... 

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

Examples

VB.NET

        comboTarget.DropDown.Dropped = True
    ElseIf e.state = SftBoxOLEDragOverConstants.leaveSftBox Then
        ' Hide the drop down portion with a delay, in case the
        ' user is moving from/to the static or drop down portion
        comboTarget.DropDown.RollUp(500)  ' 1/2 second
    End If
End Sub

Private Sub comboTarget_OLEDragDrop(ByVal sender As Object, ByVal e As AxSftBoxLib50._ISftBoxEvents_OLEDragDropEvent) Handles comboTarget.OLEDragDrop
    If e.data.GetFormat(SftOLEClipboardConstants.sftCFText) Then
        Dim itemIndex As Integer
        itemIndex = comboTarget.Items.Insert(e.data.GetData(SftOLEClipboardConstants.sftCFText), comboTarget.Items.DropIndex)
        comboTarget.Items.Selection = itemIndex
    End If
    If e.data.GetFormat(SftOLEClipboardConstants.sftCFBitmap) Then
        Dim itemIndex As Integer

VB6

        ComboTarget.DropDown.Dropped = True
    ElseIf State = leaveSftBox Then
        ' Hide the drop down portion with a delay, in case the
        ' user is moving from/to the static or drop down portion
        ComboTarget.DropDown.RollUp 500  ' 1/2 second
    End If
End Sub

Private Sub ComboTarget_OLEDragDrop(Data As SftBoxLib50.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim ItemIndex As Long
    If Data.GetFormat(sftCFText) Then
        ItemIndex = ComboTarget.Items.Insert(Data.GetData(sftCFText), ComboTarget.Items.DropIndex)
        ComboTarget.Items.Selection = ItemIndex
    End If
    If Data.GetFormat(sftCFDIB) Then
        ItemIndex = ComboTarget.Items.Insert("A Bitmap", ComboTarget.Items.DropIndex)

C#

        comboTarget.DropDown.Dropped = true;
    } else if (e.state == SftBoxOLEDragOverConstants.leaveSftBox) {
        // Hide the drop down portion with a delay, in case the
        // user is moving from/to the static or drop down portion
        comboTarget.DropDown.RollUp(500);  // 1/2 second
    }
}

private void comboTarget_OLEDragDrop(object sender, AxSftBoxLib50._ISftBoxEvents_OLEDragDropEvent e)
{
    if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFText)) {
        int itemIndex = comboTarget.Items.Insert(e.data.GetData(SftOLEClipboardConstants.sftCFText) as string, comboTarget.Items.DropIndex);
        comboTarget.Items.Selection = itemIndex;
    }
    if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFBitmap)) {
        int itemIndex = comboTarget.Items.Insert("A Bitmap", comboTarget.Items.DropIndex);

See Also SftBox Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.