Solved

Open file by drag and drop?

Posted on 2003-11-11
13
339 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
[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
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 40 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

617 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