I have some C++ / ATL objects which are trying to capture the onscroll
event of whatever page(s) is/are being displayed to the user. My basic
flow of setting up this event handlers are:
1) Sink with the DWebBrowserEvents2 of the pointer that is given to the
SetSite() method of my Browser Helper Object.
2) In DocumentComplete(), get a pointer to the IHTMLWindow2 interface
associated with the IWebBrowser2 object given to me. Sink with
HTMLWindowEvents2 on this IHTMLWindow2 interface using AtlAdvise.
3) In BeforeNavigate2, disconnect from the sink on the IHTMLWindow2
interface by using AtlUnadvise.
The two issues I am experiencing are:
a) On about 95% of webpages, I am able to catch onscroll events for
every frame in the page using this method. However, on some webpages
onscroll does not get fired AT ALL. One particular page that this
happens on is www.yahoo.com. Even though AtlAdvise returned S_OK, the
IDispatch::Invoke that I passed it never gets called with
DISPID_HTMLWINDOWEVENTS2_ONSCRLL. This IDispatch interface DOES get
called with other events, such as onunload, etc. It seems like only
the onscroll method is not working correctly.
b) I've only seen this happen on one website (www.wikipedia.org). I
actually do get onscroll events whenever I should, and I then get the
IHTMLWindow2 interface that I originally called onscroll on. I query
for the IHTMLBody2 interface, and ask for scrollTop and scrollLeft.
They ALWAYS return 0, regardless of where the scrollbar is located. On
every other page I have ever tested, the exact same code works just
I'm not sure if either / both of these are bugs or user error. But any
advice would be appreciated.