tags:

views:

74

answers:

1

When you implement IDropTarget you must implement this:

virtual HRESULT STDMETHODCALLTYPE Drop( 
            /* [unique][in] */ __RPC__in_opt IDataObject *pDataObj,
            /* [in] */ DWORD grfKeyState,
            /* [in] */ POINTL pt,
            /* [out][in] */ __RPC__inout DWORD *pdwEffect)=0;

I want to know what kind of data is coming in the IDataObject.

I did this:

FORMATETC fdrop = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};

      if (SUCCEEDED(pDataObj->QueryGetData(&fdrop)) ){
       STGMEDIUM stgMedium = {0};
       stgMedium.tymed = TYMED_HGLOBAL;
       HRESULT hr = pDataObj->GetData(&fdrop, &stgMedium);
       if (SUCCEEDED(hr))
       {

But this only works when someone drop files. I saw that there's also a CF_TEXT and CF_BITMAP, but I don't want to query for all types of Clipboard Formats, so I want to know if there's a way of querying IDataObject's type of data.

CF_HDROP works fine for files, but when I drop an image from a browser for example, I don't know what kind of CF_ to use... I tried CF_BITMAP but doesn't work.

Any ideas?

+1  A: 

See IDataObject::EnumFormatEtc. As you can see from the documentation it may be possible to query for the data in multiple formats and EnumFormatEtc is a means to enumerate the various formats available.

imaginaryboy
Thanks a lot. I looked at the documentation several times, I don't know how I did not see that.
Franco