Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 967
  • Last Modified:

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
0
orangutang
Asked:
orangutang
  • 8
  • 7
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
Mike TomlinsonMiddle 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
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now