Solved

Drag&Drop: VB _TO_ other apps

Posted on 1997-05-19
6
165 Views
Last Modified: 2012-05-04
My question is essentially the inverse of QID=857726333 (not that that helps any, I'm sure ...)

I need to be able to have a VB application act as a D&D source, with the target some other application. The trick is that I need to be able to specify what type of data is being passed.

Specifically, I want to be able to begin a drag operation in VB, from ANY control, so that the user can drop on PowerPoint (although, the target shouldn't matter). The information that I want passed along is the same information that File Manager/Explorer would sent PowerPoint if I attempted to drag&drop a file.

Really, I just want to be able to tell Windows "Hey, I'm dragging a fileName/file reference, you can do whatever you want with it when I drop it on you" - just as a File Manager / Explorer drag and drop operation does.

I've already encountered the SHELL.DLL routines to _receive_ a Drag&Drop, I need to know how to initiate this operation and specify that the destination app will receive a file / file reference (of my choosing, of course).

Thanks in Advance ...

Slade
0
Comment
Question by:Slade
  • 4
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
tward earned 150 total points
ID: 1426400
You should (I haven't tried it) be able to use the SendMessage API call.

You would want to send the WM_DROPFILES message and the application that you dropped the file on should take it from there.....
0
 

Author Comment

by:Slade
ID: 1426401
That's fine, but I'm concerned about how to 'tell' the target application (being dropped upon) WHICH file(s) are being dropped. I realize I can use SendMessage() to send the WM_DROPFILES message, but what do I need to supply for wParam and lParam?
I either need to know the actual values, or where to find them. (I've got the Win16 SDK)

Thanks in advance,

Slade


0
 

Author Comment

by:Slade
ID: 1426402
By the way ...

All of the documentation refers to a data structure called HDROP to which I need to create a handle hDrop (WORD). I can't find ANYWHERE any reference to how this structure is defined!
If I could find the structure, I'd be finished.
Any ideas?

Thanks,

Slade
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:tward
ID: 1426403
I haven't been able to find the defined structure either....
0
 

Author Comment

by:Slade
ID: 1426404
Hmmm,

Any other ideas of where to look? I can't do what I need to do without it  :(

Thanks,

Slade


0
 

Author Comment

by:Slade
ID: 1426405
In case anyone else goes looking for this information, the data structure pointed to by HDROP is undocumented. I ended up finding it in an old MSDN CD I had lying around (Apr. 1994).

It turns out the typedef for the data structure is:

typedef struct {
  WORD wSize;  // size of data structure
  POINT ptMousePos;  // position of mouse pointer on drop
  BOOL fInNonClientArea;  // mouse in non-client area on drop?
  BOOL Unicode;  // pathnames use unicode? (only for Win32 -
                 // Win16 does not have this parameter!)
} DROPFILESTRUCT *LPDROPFILESTRUCT;


The trick is that to add a filename, you have to use GlobalReAlloc() to increase the size of the data structure. The pathname(s) are appended to the end of the structure - right after the Unicode parameter. The pathnames must be preceeded by a 0-value character (chr$(0)) and followed by one:

chr$(0) + pathname + chr$(0)

The last pathname has an additional chr$(0) character to indicate that there are no more pathnames:

... + chr$(0) + pathname + chr$(0) + chr$(0)

When adding pathnames to the structure, you have to make sure that you update the wSize parameter accordingly.

Note: On Win32 systems, path names using Unicode systems require a different amound of memory to store than non-Unicode strings!


I haven't tried the above yet, I just have to figure out how to translate all the C++ code in the MSDN example into VB.

Hope this helps someone else ...

Slade


0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now