Article ID: 185675
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Foundation Class Library 4.2, when used with:
- Microsoft Visual C++ 2.0 Professional Edition
- Microsoft Visual C++ 4.0 Standard Edition
- Microsoft Visual C++ 4.1 Subscription
- Microsoft Visual C++ 4.2 Enterprise Edition
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 4.2 Professional Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ 1.52 Professional Edition
This article was previously published under Q185675
SYMPTOMS
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.
CAUSE
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().
RESOLUTION
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);
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Microsoft Visual C++ .NET.
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by
Jaganathan Thangavelu, Microsoft Corporation
Additional query words: 0x80040064 [ASCII 150]2147745892
Keywords: kbbug kbfix kbnoupdate KB185675