The seminal article on BHO is at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/bho.asp?frame=true&hidetoc=true
In it you'll find this:
To intercept the events fired by the browser, the BHO needs to connect to it via an IConnectionPoint interface and pass the IDispatch table of the functions that will handle the various events. The pointer to IConnectionPointContainer obtained previously is used to call the FindConnectionPoint method that returns a pointer to the connection point object for the required outgoing interface: in this case, DIID_DWebBrowserEvents2. The following code shows how the connection takes place:
HRESULT CViewSource::Connect(void) { HRESULT hr; CComPtr<IConnectionPoint> spCP;
// Receives the connection point for WebBrowser events hr = m_spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &spCP); if (FAILED(hr)) return hr;
// Pass our event handlers to the container. Each time an event occurs // the container will invoke the functions of the IDispatch interface // we implemented. hr = spCP->Advise( reinterpret_cast<IDispatch*>(this), &m_dwCookie); return hr; }
(it goes on...)
Good luck, William
|