Results 1 to 4 of 4

Thread: Destination of drag&drop

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Uppsala, Sweden
    Posts
    4

    Post

    How do i get the path for where i drag&drop stuff? I have an listview with filenames, and i want to drag them into a folder. The files are then downloaded via ftp to that folder. Does any one know how to get the destination of the "drop"?

    // Peter

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try something like this:
    Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Form_Load()
        Dim iIndex As Integer
        For iIndex = 1 To 10
            ListView1.ListItems.Add , , "File" & iIndex & ".txt"
        Next
    End Sub
    
    Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Begin Drag Operation when Left Mouse is Pressed
        If Button = 1 Then ListView1.OLEDrag
    End Sub
    
    Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)
        Dim sFile As String
        Dim vItem As Variant
        
        If DataFormat = vbCFFiles Then
            'Wait until the Mouse Button is Released
            If GetAsyncKeyState(vbLeftButton) = 0 Then
                For Each vItem In ListView1.ListItems
                    If vItem.Selected Then
                        'Download the Selected File(s) to a Temporary File
                        sFile = "C:\Windows\Temp\" & vItem.Text
                        Open sFile For Output As 1
                        Close 1
                        'Add the File to the Data List of Files
                        Data.Files.Add sFile
                    End If
                Next
            End If
        End If
    End Sub
    
    Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
        'Begin Drag Operation by setting the Effect of Dropping the Source
        AllowedEffects = vbDropEffectMove Or vbDropEffectCopy
        'Make sure the Data is Clear
        Data.Clear
        'Just Set the type of Data, this Forces the Target to Prompt us
        'For the Actual Data when it's time to transfer, which is what
        'we want to do as we don't actually have the file yet.
        Data.SetData , vbCFFiles
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Uppsala, Sweden
    Posts
    4

    Post

    Thanks Aaron!
    Thats how i did too, but do you think there is a way to get the destination with an API (eg. sendmessage)?

    // Peter

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You don't need to know the Destination, the File you Download to a Temporary Location is moved to the Correct Location by the Target, ie, Explorer.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width