capturing the onscroll event in C++

capturing the onscroll event in C++

Post by Zach » Sat, 09 Apr 2005 00:59:50

I have some code which is connected through a BHO and I'm trying, every
time a page is loaded, to hook into the onscroll event for every frame
on the page.

My code looks something like this:

bool WindowScrollEventInfo::AttachEvent(CComPtr<IHTMLWindow2> apWindow)
CComPtr<IUnknown> apWindowUnk;
CComPtr<IUnknown> apSinkUnk;

apWindowUnk = m_apWindow;

CComObject<WindowScrollEventSink> *pSink;
CComObject<WindowScrollEventSink>::CreateInstance(&pSink); //My own
event sink object
hr = pSink->QueryInterface(IID_IUnknown, (LPVOID *)&apSinkUnk);
if (FAILED(hr))
return m_bAttached = false;
hr = AtlAdvise(apWindowUnk, apSinkUnk, DIID_HTMLWindowEvents2,
if (FAILED(hr))
return m_bAttached = false;
return m_bAttached = true;

This works fine on about 99% of pages. The method
WindowScrollEventSink::Invoke gets called as expected with a value of

However, there are specific websites I've identified on which I never
receive scroll events no matter what I do. So far, I've identified

as being of this nature. They all execute the above code, and I can
verify that all HRESULTs are getting returned as S_OK. In fact, all of
them receive other events just fine, including
Scroll seems to just be a rogue event though, not getting fired.

Is there some kind of HTML or javascript or something that the webpage
can specify to prevent me from receiving this event?

Thanks in advance

1. handling onscroll event of WebBrowser (repost)

2. Help with Opera & onscroll event.

Hi, I have a function that I want to execute "onscroll" in Opera. But
I found that if a user has smooth scrolling enabled in the Opera
preferences, it makes Opera fire a scroll event multiple times. (I
guess that's how they achieve the smooth effect)

So how could I make it so that the onscroll event is fired once per
user scroll, but not per automatic scroll that Opera generates. Does
that make sense? :-)

I guess I want to do something like:

if (lots of automatic scrolls events){
for(the last scroll event){
//do stuff (for people that have smooth scrolling turned
window.onscroll = //do stuff (for people that have smooth
scrolling turned off)

3. c# - listbox onScroll event

4. How to sink OnScroll event in IE using attachEvent or put_onscroll?

5. onscroll event in iframe in IE

6. Detecting if onscroll events working / supported in Firefox

7. onscroll Event Not Firing in ASP.NET 2.0

8. HTMLWindowEvents2 onscroll event not getting fired

9. c# - listBox onScroll event

10. handling onscroll event of WebBrowser

11. IE 8 - JavaScript onscroll event

12. Capturing keyboard-mouse events from a wmp ui plugin, using c++ wi

13. Capturing outlook events not working with C++

14. Can I capture AS events from enclosed C++ application without do any changes on SWF?

15. How to capture WebBrowser's OnAfterPrint event in C++?