IDataObject  LQWB47

The IDataObject interface specifies methods that enable data transfer and notification of changes in data. Data transfer methods specify the format of the transferred data along with the medium through which the data is to be transferred. Optionally, the data can be rendered for a specific target device. In addition to methods for retrieving and storing data, the IDataObject interface specifies methods for enumerating available formats and managing connections to advisory sinks for handling change notifications.

The term  data object  is used to mean any object that supports an implementation of the IDataObject interface. Implementations vary, depending on what the data object is required to do; in some data objects, the implementation of certain methods not supported by the object could simply be the return of E_NOTIMPL. For example, some data objects do not allow callers to send them data. Other data objects do not support advisory connections and change notifications. However, for those data objects that do support change notifications, OLE provides an object called a data advise holder. An interface pointer to this holder is available through a call to the helper function CreateDataAdviseHolderAP85R9. A data object can have multiple connections, each with its own set of attributes. The OLE data advise holder simplifies the task of managing these connections and sending the appropriate notifications.

When to Implement

Implement the IDataObject interface if you are developing a container or server application that is capable of transferring data. For example, if your application allows its data to be pasted or dropped into another application, you must implement the IDataObject interface. OLE compound document object servers that support objects that can be embedded or linked must implement IDataObject.

OLE provides implementations in its default object handler and its cache.

When to Use

Any object that can receive data calls the methods in the IDataObject interface.

When you call the data transfer methods in the IDataObject interface, you specify a format, a medium, and, optionally, a target device for which the data should be rendered. Objects, such as containers, that want to be notified through their advise sinks when the data in the data object changes call the IDataObject advisory methods to set up an advisory connection through which notifications can be sent.

Methods in VTable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments reference count.

ReleaseDUW01A

Decrements reference count.

 

IDataObject Methods

Description

GetData81EL5_

Renders the data described in a FORMATETC8CSQ18 structure and transfers it through the STGMEDIUM0NJIOV structure.

GetDataHere3OHMFJE

Renders the data described in a FORMATETC structure and transfers it through the STGMEDIUM structure allocated by the caller.

QueryGetData31KJZ6I

Determines whether the data object is capable of rendering the data described in the FORMATETC8CSQ18 structure.

GetCanonicalFormatEtc2LYVG_P

Provides a potentially different but logically equivalent FORMATETC structure.

SetData1ZR_RYO

Provides the source data object with data described by a FORMATETC8CSQ18 structure and an STGMEDIUM0NJIOV structure.

EnumFormatEtc3D9Y8W4

Creates and returns a pointer to an object to enumerate the FORMATETC supported by the data object.

DAdvise38JBOZP

Creates a connection between a data object and an advise sink so the advise sink can receive notifications of changes in the data object.

DUnadvise25VVBL

Destroys a notification previously set up with the DAdvise method.

EnumDAdvise5VCTQV

Creates and returns a pointer to an object to enumerate the current advisory connections.