I recently noticed that I'm unable to capture the OnSroll events of the "top" window in my BHO if I'm showing a page in IE9 and the page contais the tag: <meta http-equiv="X-UA-Compatible" content="IE=9">.
I capture the scroll by sinking the DISPID_HTMLWINDOWEVENTS2_ONSCROLL of DIID_HTMLWindowEvents2 in the IHTMLWindow2 of the Top Document, and it works fine in all cases, except if the page contains that meta tag.
My sink class is defined as:
class CIEPage : public IDispEventImpl<1, CIEPage, &DIID_HTMLDocumentEvents2, &LIBID_MSHTML, 4, 0>,
public IDispEventImpl<2, CIEPage, &DIID_HTMLWindowEvents2, &LIBID_MSHTML, 4, 0>
// SinkMap
BEGIN_SINK_MAP(CIEPage)
SINK_ENTRY_EX(1, DIID_HTMLDocumentEvents2, DISPID_HTMLELEMENTEVENTS2_ONMOUSEOVER, OnMouseOver)
SINK_ENTRY_EX(2, DIID_HTMLWindowEvents2, DISPID_HTMLWINDOWEVENTS2_ONSCROLL, OnScroll)
END_SINK_MAP()
And i'm sinking like this.
hr = IDispEventImpl<1, CIEPage, &DIID_HTMLDocumentEvents2, &LIBID_MSHTML, 4, 0>::DispEventAdvise(_spDocument);
if(SUCCEEDED(hr))
_bAdvised[ListenerEventMouseOver] = true;
if(IsTopPage())
{
hr = _spDocument->get_parentWindow(reinterpret_cast<IHTMLWindow2 **>(&_spWindow));
if (SUCCEEDED(hr) && _spWindow)
{
hr = IDispEventImpl<2, CIEPage, &DIID_HTMLWindowEvents2, &LIBID_MSHTML, 4, 0>::DispEventAdvise(_spWindow);
if(SUCCEEDED(hr))
_bAdvised[ListenerEventScroll] = true;
}
}
where _spDocument is a CComPtr<IHTMLDocument2>
and _spWindow a CComPtr<IHTMLWindow2>
Any ideias? Also it seems to exist a mismatch in IE9 SDK headers and the documentation of msdn. For example the new document events of IE 9 in the documents define many events that aren't available in the SDK. This is the definition in the mshtml.idl
[
hidden,
uuid(30510737-98b5-11cf-bb82-00aa00bdce0b)
]
dispinterface HTMLDocumentEvents4
{
properties:
methods:
[id(DISPID_HTMLDOCUMENTEVENTS4_ONMSTHUMBNAILCLICK)] void onmsthumbnailclick([in] IHTMLEventObj* pEvtObj);
[id(DISPID_HTMLDOCUMENTEVENTS4_ONMSSITEMODEJUMPLISTITEMREMOVED)] void onmssitemodejumplistitemremoved([in] IHTMLEventObj* pEvtObj);
};
Since, there is now according to the msdn a OnScrollEvent on a document, maybe it's that event that I need to sink if the browser is version 9 and the page contais the IE=9... but the SDK doesn't contain that information...
Any help is appreciated. Thanks.