|
-
Aug 23rd, 2003, 11:37 AM
#1
Thread Starter
PowerPoster
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.
-
Aug 23rd, 2003, 12:02 PM
#2
The picture isn't missing
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  .
-
Aug 23rd, 2003, 12:53 PM
#3
Thread Starter
PowerPoster
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:
Option Explicit
Private Sub Form_Load()
With ListView1
.ListItems.Add , , "file1.txt", 1
.ListItems.Add , , "file2.txt", 1
.ListItems.Add , , "file3.txt", 1
.ListItems.Add , , "file4.txt", 1
End With
End Sub
Private Sub ListView1_OLEStartDrag(Data As [b]MSComctlLib[/b].DataObject, AllowedEffects As Long)
Dim intX As Integer
For intX = 1 To ListView1.ListItems.Count
If ListView1.ListItems(intX).Selected Then
Data.Files.Add App.Path & "\" & ListView1.ListItems(intX).Text
End If
Next
Data.SetData , 15 '15 = files
AllowedEffects = vbDropEffectCopy
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|