[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Drag&Drop: VB _TO_ other apps

Posted on 1997-05-19
6
Medium Priority
?
199 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

872 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