views:

346

answers:

1

I have a proprietary application with the only way to pass data externally - drag and drop from other application (like dragging a file from Windows explorer). My question is, is it possible to simulate drag'n'drop from external applicaiton? Pure win32 solution preferred, dependencies like MFC and WTL could be included too. Help!

A: 

I think it is possible, but you will probably need COM for that (I'm not sure though - there is a WM_DROPFILES message, and some related functions, but I couldn't find one for dropping data). See this article on MSDN.

Tamás Szelei
WM_DROPFILES (which is an obsolete message meant for backwards compatibility) can be sent from one app to another using SendMessage(), but it only works for sending file names, nothing else. To drag/drop actual data, you need to use the IDropTarget and IDataObject interfaces instead. You can't simulate a drag-drop with them, though. An external app has to call DoDragDrop() with valid IDropSource and IDataObject interfaces, and then the drag-drop is up to the user to complete. A window's IDropTarget interface cannot be accessed directly.
Remy Lebeau - TeamB
An app can put an IDataObject interface onto the clipboard using OleSetClipboard(), though. Anotehr app can then retreive it using OleGetClipboard().
Remy Lebeau - TeamB
@Remy, unfortunately, it sounds like they don't have access to the source of the "proprietary" app..
Chris Lively
Exactly. Sorry for misunderstanding. There is no source of proprietary app. It accepts incoming data from windows explorer as drag'n'drop file operation, and then processes the data in that file, this is all known methods to pass data. According to spy++, app does not receive anything interesting and d'n'd related, only WM_MOUSEMOVE, WM_NCHITTEST, WM_MOUSEUP. I'm going to explore the COM interfaces though, however I'm not a COM guy at all :(
aloneguid