|
|
|
date: Mon, 10 Mar 2008 13:22:05 -0700 (PDT),
group: microsoft.public.inetsdk.programming.webbrowser_ctl
back
Advise DIID_HTMLElementEvents2 events
Hi all,
I am trying to catch DIID_HTMLElementEvents2 events in a BHO. I
couldn't get the following code to work. I got E_NOINTERFACE from hr =
pCPC->FindConnectionPoint(DIID_HTMLDocumentEvents, &m_pCP); Any help
is appreciated.
STDMETHODIMP CHelloWorldBHO::SetSite(IUnknown* pUnkSite)
{
HRESULT hr;
// Check that this is a connectable object.
if(pUnkSite == NULL)
{
if (NULL != m_pCP)
{
m_pCP->Unadvise(m_dwAdviseCookie);
m_pCP = NULL;
}
if (NULL != m_pCP2)
{
m_pCP2->Unadvise(m_dwAdviseCookie2);
m_pCP2 = NULL;
}
m_pSite = NULL;
return S_OK;
}
else
{
m_pSite = pUnkSite;
CComPtr<IConnectionPointContainer> pCPC;
// Check that this is a connectable object.
hr = m_pSite->QueryInterface(IID_IConnectionPointContainer,
(void**)&pCPC);
if (SUCCEEDED(hr))
{
// Find the connection point.
hr = pCPC->FindConnectionPoint(DIID_HTMLDocumentEvents,
&m_pCP);
if (SUCCEEDED(hr))
{
// Advise the connection point.
// pUnk is the IUnknown interface pointer for your event
sink
hr = m_pCP->Advise(static_cast<IDispatch*>(this),
&m_dwAdviseCookie);
if (FAILED(hr))
{
ATLTRACE(_T("CTheBehavior::SetSite Advise failed: %8X\n"), hr);
}
}
// Find the connection point.
hr = pCPC->FindConnectionPoint(DIID_HTMLElementEvents2,
&m_pCP2);
if (SUCCEEDED(hr))
{
// Advise the connection point.
// pUnk is the IUnknown interface pointer for your event
sink
hr = m_pCP2->Advise(static_cast<IDispatch*>(this),
&m_dwAdviseCookie2);
if (FAILED(hr))
{
ATLTRACE(_T("CTheBehavior::SetSite Advise(2) failed: %8X\n"),
hr);
}
else
{
}
}
}
}
date: Mon, 10 Mar 2008 13:22:05 -0700 (PDT)
author: unknown
|
|