Solved

OLEDragDrop/Data.Files Problem

Posted on 2006-11-03
15
901 Views
Last Modified: 2008-01-09
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
Comment
Question by:orangutang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17873514
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
 
LVL 22

Author Comment

by:orangutang
ID: 17874967
No, it still doesn't work.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17875051
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 22

Author Comment

by:orangutang
ID: 17875065
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17876635
You're not using VB6 are you?

Are you using VBA in Word or Excel?
0
 
LVL 22

Author Comment

by:orangutang
ID: 17877058
No, I'm using VB6
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 17877187
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
 
LVL 22

Author Comment

by:orangutang
ID: 17877482
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17878298
Let me test it out...

On my system (WinXP Pro SP2), dragging the recycle bin did nothing.
0
 
LVL 22

Author Comment

by:orangutang
ID: 17882050
But the rest of the files are added?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17907865
(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
 
LVL 22

Author Comment

by:orangutang
ID: 17910337
I know but it's really bothering me why it doesn't add anything at all.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17910371
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
 
LVL 22

Author Comment

by:orangutang
ID: 17910408
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
 
LVL 22

Author Comment

by:orangutang
ID: 17997861
I guess no one knows the solution. Oh, well. Thanks, anyway
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question