Hide

SftDirectory 3.5 - ActiveX File/Folder Control

Display
Print

SftDirectory.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, Folder As SftDirectoryFolder, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, DefaultHandling As Boolean)
C#.NETvoid object_OLEDragDrop(object sender, EventArgumentType e);
VC++void OnOLEDragDropobject(struct IVDMDataObject** Data, ISftDirectoryFolder** Folder, long* Effect, short* Button, short* Shift, float* x, float* y, VARIANT_BOOL* DefaultHandling);
CHRESULT OnOLEDragDropobject(struct IVDMDataObject** Data, ISftDirectoryFolder** Folder, long* Effect, short* Button, short* Shift, float* x, float* y, VARIANT_BOOL* DefaultHandling);

object

A SftDirectory 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 method and Clear methods cannot be used here.

Folder

Describes the target folder where the data was dropped. Folder may be Nothing (NULL), in which case the data is dropped on the control, not on a particular folder. Folder can be Nothing (NULL) only if the ControlStyle property is set to styleSftDirectoryDetailList or styleSftDirectoryComboBoxDetailList.

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
constSftControlLeftButton1The left mouse button was pressed.
constSftControlRightButton2The middle mouse button was pressed.
constSftControlMiddleButton4The 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
constSftControlShiftMask1The SHIFT key is down.
constSftControlCtrlMask2The CONTROL key is down.
constSftControlAltMask4The 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.

DefaultHandling

On return, determines how the data is processed.

DefaultHandlingDescription
TrueThe control's default handling for the event takes place.
FalseThe application has completely processed the event and no further action by the control is desired.

Comments

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

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

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    AxSftDirectory1.OLEDropMode = SftControlOLEDropModeConstants.OLEDropSftControlManual
    AxSftDirectory1.AutoExpandDragDrop = True
End Sub

Private Sub AxSftDirectory1_OLEDragDrop(ByVal sender As Object, ByVal e As AxSftDirectoryLib30._ISftDirectoryEvents_OLEDragDropEvent) Handles AxSftDirectory1.OLEDragDrop
    ' make sure the control doesn't perform its usual default handling of
    ' the files (copy/move, etc.)
    e.defaultHandling = False

    If e.data.GetFormat(SftOLEClipboardConstants.sftCFFiles) Then
        Dim I As Integer
        For I = 1 To e.data.Files.Count
            MessageBox.Show("""" & e.data.Files(I) & """ being dropped.")
            ' perform your own processing here
        Next

VB6

Private Sub Form_Load()
    SftDirectory1.OLEDropMode = OLEDropSftControlManual
    SftDirectory1.AutoExpandDragDrop = True
End Sub

Private Sub SftDirectory1_OLEDragDrop(Data As SftDirectoryLib30.DataObject, _
        Folder As SftDirectoryLib30.ISftDirectoryFolder, Effect As Long, _
        Button As Integer, Shift As Integer, x As Single, y As Single, _
        DefaultHandling As Boolean)
    If Data.GetFormat(sftCFFiles) Then
        For i = 1 To Data.Files.Count
            MsgBox ("""" & Data.Files.Item(i) & """ being dropped.")
            ' perform your own processing here
        Next
    Else
        ' some other format

C#

private void Form1_Load(object sender, System.EventArgs e)
{
    axSftDirectory1.OLEDropMode = SftControlOLEDropModeConstants.OLEDropSftControlManual;
    axSftDirectory1.AutoExpandDragDrop = true;
}

private void axSftDirectory1_OLEDragDrop(object sender, AxSftDirectoryLib30._ISftDirectoryEvents_OLEDragDropEvent e)
{
    // make sure the control doesn't perform its usual default handling of
    // the files (copy/move, etc.)
    e.defaultHandling = false;

    if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFFiles)) {
        for (int i = 0 ; i < e.data.Files.Count ; ++i) {
            MessageBox.Show("\"" + e.data.Files[i+1] + "\" being dropped.");
            // perform your own processing here

C++

    m_vDir1 = m_Dir1.GetControlUnknown();

    m_vDir1->OLEDropMode = OLEDropSftControlManual;
    m_vDir1->AutoExpandDragDrop = VARIANT_TRUE;
    return TRUE;
}

void COLEDragDlg::OnOLEDragDropSftDirectory1(LPDISPATCH FAR* Data, LPDISPATCH FAR* Folder, long FAR* Effect, short FAR* Button, short FAR* Shift, float FAR* x, float FAR* y, BOOL FAR* DefaultHandling)
{
    IVDMDataObjectPtr pData(*Data);
    ISftDirectoryFolderPtr pFolder(*Folder);

    if (pData->GetFormat(sftCFFiles)) {
        int i;
        for (i = 1 ; i <= pData->Files->Count ; ++i) {
            CString str;

See Also SftDirectory Object | Object Hierarchy


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