Solved

Open file by drag and drop?

Posted on 2003-11-11
13
334 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

828 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