views:

403

answers:

1

hi guys,
This sounds funny..just a little experiment.
i wanted to simulate a drag drop of a file on a Application/Window using Send Message. Is it possible?

I dont have code for the application but on the executable.

The application is IP Messenger.

What i wanted to do is use "Send To" functionality to send the file to an .exe ,which will
find IPMessenger window and simulate a drag drop thr code.

The user will select the file and right click "send to" to the .exe which will do drag drop from code.

**Note: IP Messenger supports drag-drop operation for files

thx
amit

+1  A: 

There is the WM_DROPFILES Message. I guess that you could use the CreateToolhelp32Snapshot Function to locate the window that is IP Messenger and then build the DROPFILES structure to send with the WM_DROPFILES message.

The final link would be to Codeproject, with some help on creating the DROPFILES structure: How to Implement Drag and Drop Between Your Program and Explorer.

Was it something like this you were after..?


Actually I might be mistaken (that's a first!) :)
Instead of using CreatToolhelp32Snapshot you could be using FindWindow function. Here you will get the HWND for IP Messenger directly, instead of CTh32S, which will only locate the HANDLE for the process.

When this is done you create the DROPFILES structure. It's a cumbersome task, as described by Michael Dunn on CodeProject, but I think that if you read his comments on the Initiating a drag and drop section I think you'll figure it out.

And finally you send it with sendmessage

SendMessage(ipMessHWND, WM_DROPFILES, (HDROP)&myDropFiles, 0);

Remember: it's only hard the first time :)

Default
just about what i was looking for.looks pretty complex.Thx :)
Amitd
I added some more to hopefully make it clearer
Default