?
Solved

Open file by drag and drop?

Posted on 2003-11-11
13
Medium Priority
?
340 Views
Last Modified: 2010-05-01
Hello,
how can i load a file by drag a file (from explorer) with the mouse and drop it on my running application (myprog.exe)?
bye
Ramoni
0
Comment
Question by:Ramoni
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9721214
0
 

Author Comment

by:Ramoni
ID: 9721352
sorry,
but the micro-source link doesn't work
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9721515
Hi Ramoni,
I've just tried it again & it works OK for me. I even started, but cancelled, the download.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:aelatik
ID: 9721615
Set your form to recieve drops ( OleDropmode = 1) and use the following code ..

Private Sub Form_Load()
    Me.OLEDropMode = 1
End Sub

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    For Each Item In Data.Files
        MsgBox Item ' You can place your code here to handle the file
    Next
End Sub
0
 
LVL 2

Expert Comment

by:cofneverlivetotell
ID: 9729410
Shell ("NAME OF YOUR PROGRAM /s PATH OF FILE TO DRAG"), vbNormalFocus

eg, Shell ("regedit /s C:\Windows\Desktop\reg.reg "), vbNormalFocus

Cofneverlivetotell
cofneverlivetotell@hotmail.com
0
 

Author Comment

by:Ramoni
ID: 9764775
Hello,
@GrahamSkan's Link doesnt work on my PC.
@cofneverlivetotell what do you want to make: i dont understand you or you dont understand me what i want.

aelatiks code is the way i thougt and tryed, but it doesnt work.
I activated the OLEDropMode
And added the code for my form:

Private Sub MDIForm1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    For Each Item In Data.Files
        MsgBox Item ' You can place your code here to handle the file
    Next
End Sub

If I test my programm, the sub MDIForm1_OLEDragDrop is never called,
is there a problem because of working with a mdi-form?

I hope for further suggestions to solve my problem
Bye
Ramoni

0
 
LVL 14

Expert Comment

by:aelatik
ID: 9765587
Are you sure you set the properties right ? Because its works in MDI also. I just tested it...
0
 
LVL 14

Expert Comment

by:aelatik
ID: 9765603
I see you have "Private Sub MDIForm1_OLEDragDrop" . Try changing it to "Private Sub MDIForm_OLEDragDrop"
0
 
LVL 14

Accepted Solution

by:
aelatik earned 120 total points
ID: 9765606
Copy and paste this :

Private Sub MDIForm_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    For Each Item In Data.Files
        MsgBox Item ' You can place your code here to handle the file
    Next
End Sub
0
 

Author Comment

by:Ramoni
ID: 9770066
@aelatik

thank you for your help: the big effect of the little 1....
0
 

Author Comment

by:Ramoni
ID: 9770175
Im here again:
what xyz? is necessary that it works if a opend child window is in the MDIForm?

Private Sub xyz?_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    For Each Item In Data.Files
        MsgBox Item ' You can place your code here to handle the file
    Next
End Sub
0
 
LVL 14

Expert Comment

by:aelatik
ID: 9770907
These are form events. When you doubleclick a form in designtime it automatically opens the form_load event section. When you have done that you can select OleDragDrop on the right top corner where it says Load.
0
 
LVL 14

Expert Comment

by:aelatik
ID: 9770912
xyz stands form the Formname
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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, 20 hours left to enroll

839 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