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

x
?
Solved

Drag Drop from VB Form to Desktop

Posted on 2008-11-04
2
Medium Priority
?
337 Views
Last Modified: 2012-06-27
Hi Guys,

  I am trying to do the following and I am not sure how. I want to be able to drag an item from a VB form (e.g an item from a listbox to the desktop or to a folder in windows explorer and this to actually paste a file there.

Thanks,
Savvas
0
Comment
Question by:AJKBOC
2 Comments
 
LVL 39

Expert Comment

by:appari
ID: 22883208
you need to use windows shell programming, check these articles on drag drop operations from MSDN

http://msdn.microsoft.com/en-us/library/bb776905(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb776904(VS.85).aspx
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 24537202
No...you can use OLE Drag/Drop with the vbCFFiles flag to allow a drag from your VB app to ANY drop target that accepts files:
(*note that for this to work, the files being dragged must actually exist!)
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        Picture1.OLEDrag
    End If
End Sub
 
Private Sub Picture1_OLESetData(Data As DataObject, DataFormat As Integer)
    ' The files being copied must actually exist!...
    Data.Files.Add "c:\someFile1.txt"
    Data.Files.Add "c:\someFile2.txt"
    Data.Files.Add "c:\someFile3.txt"
 
    ' A file that does not exist will generate an error
    ' and cancel your copy operation...
    Data.Files.Add "c:\someFileThatDoesNotExist.txt" 
End Sub
 
Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
    Data.SetData , vbCFFiles
    AllowedEffects = vbDropEffectCopy
End Sub

Open in new window

0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

578 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