IDataObject::GetCanonicalFormatEtc method (objidl.h)
Provides a potentially different but logically equivalent FORMATETC structure. You use this method to determine whether two different FORMATETC structures would return the same data, removing the need for duplicate rendering.
HRESULT GetCanonicalFormatEtc( [in] FORMATETC *pformatectIn, [out] FORMATETC *pformatetcOut );
A pointer to the FORMATETC structure that defines the format, medium, and target device that the caller would like to use to retrieve data in a subsequent call such as IDataObject::GetData. The tymed member is not significant in this case and should be ignored.
A pointer to a FORMATETC structure that contains the most general information possible for a specific rendering, making it canonically equivalent to pformatetcIn. The caller must allocate this structure and the GetCanonicalFormatEtc method must fill in the data. To retrieve data in a subsequent call like IDataObject::GetData, the caller uses the specified value of pformatetcOut, unless the value specified is NULL. This value is NULL if the method returns DATA_S_SAMEFORMATETC. The tymed member is not significant in this case and should be ignored.
This method can return the following values.
||The returned FORMATETC structure is different from the one that was passed.|
||The FORMATETC structures are the same and NULL is returned in pformatetcOut.|
||The value for lindex is not valid; currently, only -1 is supported.|
||The value for pformatetc is not valid.|
||The object application is not running.|
||An unexpected error has occurred.|
||The dwDirection parameter is not valid.|
||There was insufficient memory available for this operation.|
If a data object can supply exactly the same data for more than one requested FORMATETC structure, GetCanonicalFormatEtc can supply a "canonical", or standard FORMATETC that gives the same rendering as a set of more complicated FORMATETC structures. For example, it is common for the data returned to be insensitive to the target device specified in any one of a set of otherwise similar FORMATETC structures.IDataObject::GetData on a data object, specifying two different FORMATETC structures, would actually produce the same renderings, thus eliminating the need for the second call and improving performance. If the call to GetCanonicalFormatEtc results in a canonical format being written to the pformatetcOut parameter, the caller then uses that structure in a subsequent call to IDataObject::GetData. FORMATETC structures in groups defined by a canonical FORMATETC that provides the same results as each of the group members. In constructing the canonical FORMATETC, you should make sure it contains the most general information possible that still produces a specific rendering.
For data objects that never provide device-specific renderings, the simplest implementation of this method is to copy the input FORMATETC to the output FORMATETC, store a NULL in the ptd member of the output FORMATETC, and return DATA_S_SAMEFORMATETC.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|