IActiveDesignerRuntimeSite::GetAdviseSink

Returns a pointer to an event interface for a specific event source.

GetAdviseSink(
   MEMBERID memid,
   IUnknown **ppunkSink
);

Parameters

memid

[in] Member ID of the event source object.

ppunkSink

[out] Location to receive an IUnknown pointer to the event interface for memid.

Return Values

The return value obtained from the returned HRESULT is one of the following:

Return Value Meaning
S_OK Success.
E_FAIL The designer passed an invalid memid.

Comments

The host implements this method.

Designers call the host's GetAdviseSink method to get a pointer to an event interface for a specific object that is a source of events. Designers that call this method must set DESIGNERFEATURE_DELAYEVENTSINKING in the registry and must implement the IActiveDesignerRuntime interface.

After creating the run-time object, the host calls the designer's IActiveDesignerRuntime::SetSite method, passing a pointer to its IActiveDesignerRuntimeSite interface. When the designer is ready to fire events, it calls GetAdviseSink through this pointer and specifies the member ID (memid) of the event type to fire. To get a pointer to its own event interface, the designer specifies MEMBERID_NIL.

GetAdviseSink returns another pointer (ppunkSink), which identifies the object that implements the event interface for memid. The designer then must call ppunkSink::QueryInterface to get a pointer to the specific event interface. It can then fire events through the interface.

Example

The following example calls the host's GetAdviseSink method to get a pointer to the object that implements the event sink for memid. GetAdviseSink returns the pointer in punkEventSink. After checking for errors, the example calls this object's QueryInterface method, requesting a pointer to a dispatch interface that implements the event sink itself. QueryInterface returns this pointer in m_pdispEventSink.

hr = m_pIActiveDesignerRuntimeSite->GetAdviseSink(memid, &punkEventSink);
CSF_CHECK(hr == S_OK, hr, CSF_TRACE_INTERNAL_ERRORS);
hr = punkEventSink->QueryInterface(IID_IDispatch,
   (void**)&m_pdispEventSink);
CSF_CHECK(hr == S_OK, hr, CSF_TRACE_INTERNAL_ERRORS);

punkEventSink->Release();



See Also

IActiveDesignerRuntime, DESIGNERFEATURE_DELAYEVENTSINKING