0
votes

Is it possible to manipulate a file in a kind of drag event?

As you my know most windows programms (Outlook in this particular case) are using streams to accomplish a drag & drop operation, which certain third party programms won't understand (e.g. Firefox, Chrome). Since I am not able to alter the third party programm behavior, I tried to code an Outlook addin, that copies the file to a temp folder and manipulates (ole & com) the drop information before the drop on third party programm occurs.

I have the the following problem:

The Event on which I am interfering is a extreme workaround: The "DragEnter" COM Event within Outlook, such that a dragged email needs to cross another outlook element to be triggered. It was just for test purposes. The question is where can I globally hook up when an email is dragged and at the same time manipulate the drop information or forcing my own drag & drop (DoDragDrop(..)) ?

HRESULT TDropTarget::DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) { 
    //...
    //get data from pDataObj, create file and new IDataObject* pDataObject which points to file
    DWORD dwResult = DoDragDrop(pDataObject, pDropSource, DROPEFFECT_COPY, pdwEffect);

    if(dwResult == DRAGDROP_S_DROP) { // success!
        OutputDebugString(TEXT("DRAGDROP_S_DROP\r\n"));
    } else if (dwResult == DRAGDROP_S_CANCEL) { // cancelled
        OutputDebugString(TEXT("DRAGDROP_S_CANCEL\r\n"));
    }

    pDataObject->Release();
    pDropSource->Release();    

    return S_OK;
}
1

1 Answers

0
votes

You can dynamically patch at run-time the DoDragDrop Windows API function. You can create your own IDataObject that adds CF_HDROP format and pass that object to the original version of DoDragDrop().