I am running a BHO and i am trying to catch OnClick events using HTMLDocumentEvents2
however, the events never seem to reach the handler
this is what i am doing:
class ATL_NO_VTABLE CBlastBhoBHO :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CBlastBhoBHO, &CLSID_BlastBhoBHO>,
public IObjectWithSiteImpl<CBlastBhoBHO>,
public IDispatchImpl<IBlastBhoBHO, &IID_IBlastBhoBHO, &LIBID_BlastBhoLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IDispEventImpl<0, CBlastBhoBHO, &DIID_HTMLDocumentEvents2, &LIBID_MSHTML, 1, 0>,
public IDispEventImpl<1, CBlastBhoBHO, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>
BEGIN_SINK_MAP(CBlastBhoBHO)
SINK_ENTRY_EX(0, DIID_HTMLDocumentEvents2, DISPID_HTMLDOCUMENTEVENTS2_ONCLICK, OnClickTrigger)
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
END_SINK_MAP()
// Handlers
void STDMETHODCALLTYPE CBlastBhoBHO::OnDocumentComplete( IDispatch *pDisp, VARIANT *url) { // works fine }
void STDMETHODCALLTYPE CBlastBhoBHO::OnClickTrigger(IHTMLEventObj *pEvtObj) { // Never called }
// From SetSite()
ATL::IDispEventSimpleImpl<1,CBlastBhoBHO,&DIID_DWebBrowserEvents2>::DispEventAdvise(m_spWebBrowser);
// From OnDocumentComplete
CComQIPtr<IHTMLDocument3> doc_;
m_spWebBrowser->get_Document((IDispatch**) &doc_);
ATL::IDispEventSimpleImpl<0,CBlastBhoBHO,&DIID_HTMLDocumentEvents2>::DispEventAdvise(doc_);
I have tried several variations(using HTMLElementEvents2 etc) or Advising on different objects or Advising on the document from SetSite. my handler is never called.
Any help would be much appreciated. all i need is the onClick event.