BUG: DelayRenderFileData() Does Not Call OnRenderFileData()ID: Q185675
|
In OLE drag and drop, when using COleDataSource::DelayRenderFileData() with the default second parameter of NULL, COleDataSource::OnRenderFileData() may not be called to request the actual data.
When you call COleDataSource::DelayRenderFileData() with a clipboard format
such as CF_TEXT (or any other clipboard format) and the second parameter
FORMATETC is not specified (defaulting to NULL), _AfxFillFormatEtc() gets
called. This function creates a FORMATETC structure and populates it with
default values--it fills the "tymed" member of the FORMATETC structure with
-1. Because the "tymed" member is a DWORD, the value is effectively
0xffffffff, and therefore all TYMED enumerations are supported.
However, COleDataSource::OnRenderFileData() or your override for this
function, is called only if the user of this data requests the data with a
TYMED value of TYMED_ISTREAM or TYMED_HGLOBAL.
Because DelayRenderFileData() specified that all the TYMED enumerations are
acceptable, a client may in fact ask for data with a TYMED value other than
TYMED_ISTREAM or TYMED_HGLOBAL. This results in an HRESULT of
DATA_E_FORMATETC being returned from IDataObject::GetData().
The workaround is to call COleDataSource::DelayRenderFileData() with the second parameter explicitly specified. For example:
FORMATETC fmt = {CF_TEXT, NULL, DVASPECT_CONTENT, -1,
TYMED_ISTREAM|TYMED_HGLOBAL};
// Class derived from ColeDataSource.
COleMyDataSource *pDataSrc;
pDataSrc = new COleMyDataSource();
pDataSrc-<DelayRenderFileData(CF_TEXT, &fmt);
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by
Jaganathan Thangavelu, Microsoft Corporation
Additional query words: 0x80040064 [ASCII 150]2147745892
Keywords : kbole kbMFC kbVC kbVC200bug kbVC210bug kbVC220bug kbVC400bug kbVC410bug kbVC420bug kbVC500bug kbVC600bug
Version : WINDOWS:1.52; WINNT:2.0,2.1,2.2,4.0,4.1,4.2,5.0,6.0
Platform : WINDOWS winnt
Issue type : kbbug
Last Reviewed: July 21, 1999