IDataObject::DAdvise
Called by an
object supporting an advise sink to create a connection between a data object
and the advise sink. This enables the advise sink to be notified of changes in
the data of the object.
HRESULT DAdvise(
FORMATETC
* pFormatetc, |
//Pointer to data of interest to the advise sink |
DWORD advf, |
//Flags that specify how the notification takes
place |
IAdviseSink * pAdvSink, |
//Pointer to the advise sink |
DWORD * pdwConnection |
//Pointer to a token that identifies this connection |
); |
|
Parameters
pFormatetc
[in] Pointer
to a FORMATETC
advf
[in] DWORD
that specifies a group of flags for controlling the advisory connection. Valid
values are from the enumeration ADVF
ADVF
Value |
Description |
ADVF_NODATA |
Asks the
data object to avoid sending data with the notifications. Typically data is
sent. This flag is a way to override the default behavior. When ADVF_NODATA
is used, the TYMED |
ADVF_ONLYONCE |
Causes the
advisory connection to be destroyed after the first change notification is
sent. An implicit call to IDataObject::DUnadvise |
ADVF_PRIMEFIRST |
Asks for an
additional initial notification. The combination of ADVF_ONLYONCE and
ADVF_PRIMEFIRST provides, in effect, an asynchronous IDataObject::GetData |
ADVF_DATAONSTOP |
When
specified with ADVF_NODATA, this flag causes a last notification with the
data included to to be sent before the data object is destroyed. If used
without ADVF_NODATA, IDataObject::DAdvise can be implemented in one of
the following ways: |
|
the ADVF_DATAONSTOP
can be ignored. |
|
the object
can behave as if ADVF_NODATA was specified. |
|
a change
notification is sent only in the shutdown case. Data changes prior to
shutdown do not cause a notification to be sent. |
pAdvSink
[in] Pointer
to the IAdviseSink interface on the advisory sink that will
receive the change notification.
pdwConnection
[out] Pointer
to a DWORD token that identifies this connection. You can use this token later
to delete the advisory connection (by passing it to IDataObject::DUnadvise
Return Values
This method
supports the standard return values E_INVALIDARG, E_UNEXPECTED, and
E_OUTOFMEMORY, as well as the following:
S_OK
The advisory
connection was created.
E_NOTIMPL
This method
is not implemented on the data object.
DV_E_LINDEX
Invalid value
for lindex; currently, only -1 is supported.
DV_E_FORMATETC
Invalid value
for pFormatetc.
OLE_E_ADVISENOTSUPPORTED
The data
object does not support change notification.
Remarks
IDataObject::DAdvise creates a change notification connection between a
data object and the caller. The caller provides an advisory sink to which the
notifications can be sent when the object s data changes.
Objects used
simply for data transfer typically do not support advisory notifications and
return OLE_E_ADVISENOTSUPPORTED from IDataObject::DAdvise.
Notes to Callers
The object
supporting the advise sink calls IDataObject::DAdvise to set up the
connection, specifying the format, aspect, medium, and/or target device of interest
in the FORMATETC
Containers of
linked objects can set up advisory connections directly with the bound link
source or indirectly through the standard OLE link object that manages the
connection. Connections set up with the bound link source are not automatically
deleted. The container must explicitly call IDataObject::DUnAdvise on
the bound link source to delete an advisory connection. The OLE link object,
manipulated through the IOleLink
The OLE
default link object creates a wildcard advise with the link source so OLE can
maintain the time of last change. This advise is specifically used to note the
time that anything changed. OLE ignores all data formats that may have changed,
noting only the time of last change. To allow wildcard advises, set the FORMATETC
members as follows before calling IDataObject::DAdvise:
cf == 0;
ptd == NULL;
dwAspect ==-1;
lindex == -1
tymed == -1;
The advise
flags should also include ADVF_NODATA. Wildcard advises from OLE should always
be accepted by applications.
Notes to Implementers
To simplify
the implementation of DAdvise and the other notification methods in IDataObject
See Also