Solved

Drag&Drop: VB _TO_ other apps

Posted on 1997-05-19
6
173 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Write data from SQL to CSV file - position 1 59
Question about INSTR  - need to extract data MS ACCESS query 6 54
Visual Studio 2005 text editor 10 38
Advice in Xamarin 21 78
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

786 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