winapidrag-and-dropole

How drag-and-drop works when dragging letters or attachments from Outlook to a window of C++ program?


I want to implement drag-and-drop from MS Outlook (letters, attachments) to a window in my C++ program, using WINAPI. Dragging regular files seems to be much easier to understand - using of WM_DROPFILES message is described quite clearly.

As far as I understand to drag from Outlook OLE dragging used, but I have not found clear and structured description of this technique.

Could not tell me base points of dragging from MS Outlook (C++, WINAPI) ?


Solution

  • You need to write a class that implements the IDropTarget interface, and then register an instance of that class with your app's window using RegisterDragDrop().

    When a drag then occurs on your window, your IDropTarget instance will receive an IDataObject instance, from which you can then query what kind(s) of data are being dragged, and receive the data itself.

    See Transferring Shell Objects with Drag-and-Drop and the Clipboard on MSDN for more details.

    For example, Outlook can pass around attachments using the CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS formats.