IOleObject::Advise  Y3AWG3

Establishes an advisory connection between a compound document object and the calling object s advise sink, through which the calling object receives notification when the compound document object is renamed, saved, or closed.

HRESULT Advise(

    IAdviseSink *pAdvSink,

//Pointer to advisory sink

    DWORD *pdwConnection

//Pointer to a token

   );

 

 

Parameters

pAdvSink

[in] Pointer to the IAdviseSink interface on the advise sink of the calling object.

pdwConnection

[out] Pointer to a DWORD token that can be passed to IOleObject::Unadvise22X3DZP to delete the advisory connection.

 

Return Values

This method supports the standard return value E_OUTOFMEMORY, as well as the following:

S_OK

Advisory connection is successfully established.

 

Remarks

The Advise method sets up an advisory connection between an object and its container, through which the object informs the container s advise sink of close, save, rename, and link-source change events in the object. A container calls this method, normally as part of initializing an object, to register its advisory sink with the object. In return, the object sends the container compound-document notifications by calling IAdviseSink3F9W.KC or IAdviseSink2139LZ_S.

If container and object successfully establish an advisory connection, the object receiving the call returns a nonzero value through pdwConnection to the container. If the attempt to establish an advisory connection fails, the object returns zero. To delete an advisory connection, the container calls IOleObject::Unadvise and passes this nonzero token back to the object.

An object can delegate the job of managing and tracking advisory events to an OLE advise holder, to which you obtain a pointer by calling CreateOleAdviseHolder21F74AP. The returned IOleAdviseHolder interface has three methods for sending advisory notifications, as well as Advise, Unadvise, and EnumAdvise methods that are identical to those for IOleObject. Calls to IOleObject:Advise, Unadvise, or EnumAdvise are delegated to corresponding methods in the advise holder.

To destroy the advise holder, simply call Release on the IOleAdviseHolder interface.

See Also

CreateOleAdviseHolder, IOleObject::UnAdvise, IOleObject::EnumAdvise, IOleAdviseHolder::Advise