Results 1 to 3 of 3

Thread: OLE Drag & Drop (Drag from my app to Windows Explorer)

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    OLE Drag & Drop (Drag from my app to Windows Explorer)

    How can I set this up:
    My app will display a listview in large- or small- icon format. These icons will represent files. I would like the user to be able to drag one or more of the icons from the listview and drop them into an Explorer folder (effectively, my app would be copying these files to the desired folder). I know it's probably not rocket science, but I haven't done this before. TIA for your help...
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Private Sub ListView1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
    Data.Files.Add "C:\somesong.mp3" 'etc add all the files.
    Data.SetData , 15 '15 = files
    AllowedEffects = vbDropEffectCopy
    End Sub

    that should work.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    SWEET, Buggy! Thank you very much. Here is the test I ran based on your code. Just had to modify the sub event header slightly and set the OLEDragMode property of the LV to automatic. But this is beautiful, it opens up a lot of possiblilities for an app I have in mind. Thanks again!

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. With ListView1
    5.     .ListItems.Add , , "file1.txt", 1
    6.     .ListItems.Add , , "file2.txt", 1
    7.     .ListItems.Add , , "file3.txt", 1
    8.     .ListItems.Add , , "file4.txt", 1
    9. End With
    10. End Sub
    11.  
    12. Private Sub ListView1_OLEStartDrag(Data As [b]MSComctlLib[/b].DataObject, AllowedEffects As Long)
    13.     Dim intX    As Integer
    14.     For intX = 1 To ListView1.ListItems.Count
    15.         If ListView1.ListItems(intX).Selected Then
    16.             Data.Files.Add App.Path & "\" & ListView1.ListItems(intX).Text
    17.         End If
    18.     Next
    19.     Data.SetData , 15 '15 = files
    20.     AllowedEffects = vbDropEffectCopy
    21.  
    22. End Sub
    "It's cold gin time again ..."

    Check out my website here.

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