OLEDragDrop/Data.Files Problem

I have "On Error Resume Next" in my ListView's OLEDragDrop sub but whenever I try to drag a bunch of files from the desktop including the recycle bin, nothing is added to the list.

Here's my code:

Private Sub lvwFiles_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)
On Error Resume Next
Dim i As Long
For i = 1 To Data.Files.Count
If IsFolder(Data.Files(i)) = True Or IsFile(Data.Files(i)) = True Then
lvwFiles.ListItems.Add , , Data.Files(i)
End If
Next
End Sub
LVL 22
orangutangAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Hmm...ok.  The ListView dragdrop signature is different than the Form signature.

This works for me:

Option Explicit

Private Sub Form_Load()
    lvwFiles.OLEDropMode = 1 ' Manual
    lvwFiles.View = lvwSmallIcon
End Sub

Private Sub lvwFiles_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Data.GetFormat(vbCFFiles) Then
        Dim i As Integer
        For i = 1 To Data.Files.Count
            lvwFiles.ListItems.Add , , Data.Files(i)
        Next
    End If
End Sub
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try...

Private Sub lvwFiles_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Data.GetFormat(vbCFFiles) Then
        Dim sText As String
        Dim i As Integer
        For i = 1 To Data.Files.Count
            lvwFiles.ListItems.Add , , Data.Files(i)
        Next
    End If
End Sub
0
 
orangutangAuthor Commented:
No, it still doesn't work.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Are you even getting into the event properly?

    Private Sub lvwFiles_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Data.GetFormat(vbCFFiles) Then
            Dim i As Integer
            For i = 1 To Data.Files.Count
               MsgBox Data.Files(i)
            Next
        End If
    End Sub

Did you set the DropMode?

    Private Sub Form_Load()
        lvwFiles.OLEDropMode = 1 ' Manual
    End Sub
0
 
orangutangAuthor Commented:
It won't let me use "Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single"
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You're not using VB6 are you?

Are you using VBA in Word or Excel?
0
 
orangutangAuthor Commented:
No, I'm using VB6
0
 
orangutangAuthor Commented:
But if you accidentally drop the recycle bin with the other files into the listview, all of the files except for the recycle bin are added?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Let me test it out...

On my system (WinXP Pro SP2), dragging the recycle bin did nothing.
0
 
orangutangAuthor Commented:
But the rest of the files are added?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
(With my last code submission...)

Are you not getting any files at all?

Or is it just the recycle bin that you are worried about.  I can't add the Recycle Bin myself...but why would you want to anyways?...it is not an actual folder.
0
 
orangutangAuthor Commented:
I know but it's really bothering me why it doesn't add anything at all.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Regular files aren't getting added?

...or nothing gets added when the recycle bin is dropped?

The recycle bin is not an actual file...
0
 
orangutangAuthor Commented:
Nothing is added. I know the recycle bin isn't an actual file but I accidentally dragged it into the ListView and now it's driving me crazy that I can't get it to work if I drag the recycle bin into the list.
0
 
orangutangAuthor Commented:
I guess no one knows the solution. Oh, well. Thanks, anyway
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.