Skip to content

OLEDragDrop Event

Description

Occurs when a source component is dropped onto a target component when the source component determines that a drop can occur.

Syntax

Public Event OLEDragDrop( _
    ByVal Data As DataObject, _
    ByRef Effect As Long, _
    ByVal Button As Integer, _
    ByVal Shift As Integer, _
    ByVal x As Long, _
    ByVal y As Long _
)

Parameters

  • 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.

  • Effect: A long integer 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).

  • 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 were depressed, the value of shift would be 6.

  • x: A number which specifies the current location of the mouse pointer. 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.

  • y: A number which specifies the current location of the mouse pointer. 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.

Example

Drag and Drop Custom Items into the Task Panel (Visual Basic)

This sample illustrates how to drag and drop custom items into the task panel. This sample assumes this is a List View named wndListView.

Dim DragListItem As ListItem

Private Sub Form_Load()
    wndTaskPanel.Groups.Add 0, "Files"
    wndListView.ListItems.Add , , "File 1"
    wndListView.ListItems.Add , , "File 2"
    wndListView.ListItems.Add , , "File 3"
End Sub

Private Sub wndListView_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If (Button = vbLeftButton) Then
        Dim Item As ListItem
        Set Item = wndListView.HitTest(x, y)
        If (Not Item Is Nothing) Then
            Set DragListItem = Item
            wndListView.OLEDrag
            Set DragListItem = Nothing
        End If
    End If
End Sub

Private Sub wndListView_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    If Not DragListItem Is Nothing Then
        AllowedEffects = vbDropEffectCopy
        Data.SetData DragListItem.Text, vbCFText
    End If
End Sub

Private Sub wndListView_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    If (Data.GetFormat(vbCFText)) Then
        Effect = vbDropEffectCopy
        Dim Text As String
        Text = Data.GetData(vbCFText)
    ElseIf Data.GetFormat(vbCFFiles) Then
        Effect = vbDropEffectCopy
        For Each File In Data.Files
            wndListView.ListItems.Add , , File
        Next
    Else
        Effect = vbDropEffectNone
    End If
End Sub

Private Sub wndListView_OLEDragOver(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, state As Integer)
    If (Data.GetFormat(vbCFText)) Then
        Effect = vbDropEffectCopy
    ElseIf Data.GetFormat(vbCFFiles) Then
        Effect = vbDropEffectCopy
    Else
        Effect = vbDropEffectNone
    End If
End Sub

Private Sub wndTaskPanel_OLEDragDrop(ByVal Data As XtremeTaskPanel.DataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
    If (Data.GetFormat(vbCFText) And (Not wndTaskPanel.DragOverItem Is Nothing)) Then
        Effect = vbDropEffectCopy
        Dim Text As String
        Text = Data.GetData(vbCFText)

        If (wndTaskPanel.DragOverItem.IsGroup) Then
            wndTaskPanel.DragOverItem.Group.Items.Add 0, Text, xtpTaskItemTypeText
        Else
            wndTaskPanel.DragOverItem.Group.Items.Insert wndTaskPanel.DragOverItem.Index, 0, Text, xtpTaskItemTypeText
        End If
    Else
        Effect = vbDropEffectNone
    End If
End Sub

Private Sub wndTaskPanel_OLEDragOver(ByVal Data As XtremeTaskPanel.DataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single, ByVal state As Integer)
    If (Data.GetFormat(vbCFText)) Then
        Effect = vbDropEffectCopy
    Else
        Effect = vbDropEffectNone
    End If
End Sub

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.