Open file by drag and drop?

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
RamoniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
0
RamoniAuthor Commented:
sorry,
but the micro-source link doesn't work
0
GrahamSkanRetiredCommented:
Hi Ramoni,
I've just tried it again & it works OK for me. I even started, but cancelled, the download.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

aelatikCommented:
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
cofneverlivetotellCommented:
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
RamoniAuthor Commented:
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
aelatikCommented:
Are you sure you set the properties right ? Because its works in MDI also. I just tested it...
0
aelatikCommented:
I see you have "Private Sub MDIForm1_OLEDragDrop" . Try changing it to "Private Sub MDIForm_OLEDragDrop"
0
aelatikCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RamoniAuthor Commented:
@aelatik

thank you for your help: the big effect of the little 1....
0
RamoniAuthor Commented:
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
aelatikCommented:
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
aelatikCommented:
xyz stands form the Formname
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

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.