handling onscroll event of WebBrowser

handling onscroll event of WebBrowser

Post by Jocke » Tue, 08 Aug 2006 22:48:09


Hi Group
I'm writing an Internet Explorer plugin. Everything works well, except
when I try to handle the onscroll event.
http://www.yqcomputer.com/
http://www.yqcomputer.com/
another possibility seems to exist with IHTMLElement2.onscroll using
the document body, but this does not solve the problem.

the following code snippet compiles but when executed it always throws
a System.NotImplementedException
this is the stack trace:
in mshtml.HTMLWindow2Class.IHTMLWindow2_set_onscroll(Object p)

this is the code:
-------
//WebBrowser is a valid instance of SHDocVw.WebBrowserClass
this.WebBrowser.DocumentComplete += new
DWebBrowserEvents2_DocumentCompleteEventHandler(webBrowser_DocumentComplete);

void webBrowser_DocumentComplete(object pDisp, ref object URL)
{
mshtml.IHTMLDocument2 document =
(mshtml.IHTMLDocument2)this.WebBrowser.Document;
mshtml.IHTMLWindow2 window = document.parentWindow;

try
{
//window.onscroll =
// new mshtml.HTMLWindowEvents_onscrollEventHandler(
// this.webBrowserWindow_onscroll);
window.onscroll =
new mshtml.HTMLWindowEvents2_onscrollEventHandler(
this.webBrowserWindow_onscroll);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void webBrowserWindow_onscroll()
{
MessageBox.Show("scroll");
}
private void webBrowserWindow_onscroll(mshtml.IHTMLEventObj pEvtObj)
{
MessageBox.Show("scroll2");
}
------

any idea on what I'm doing wrong?
thanks
Claudio
 
 
 

1. OnScroll for Webbrowser control in VB

2. Resolved!! OnScroll for Webbrowser control in VB

Igor!

You gave me enough information to figure it out. You seemed to infer that
the body.scrollTop and left did exist. That's all I needed. While I wasn't
seeing those properties on the HTMLdocument.body object (hDoc), I defined an
hBody as HTMLbody, set it to hDoc.body and when you reference hBody
scrollLeft and scrollTop show! I'm not sure why that is but at this point,
I'm not asking too many questions! ;-)

Thanks once more for your guidenance.

Steve

3. How can I handle WebBrowser control events with C++?

4. Information on handling events from items within WebBrowser control with VB/C#?

5. Handling "Events" raised by objects within a WebBrowser control?

6. Handle events fired by sucessive navigate in WebBrowser

7. [tao-users] [Event handling] : [deadlock problem with TAO/event handling]

8. wxMenuBar :: encapsulating event handling :: seems that only parent frame handles these events

9. capturing the onscroll event in C++

10. onscroll event in iframe in IE

11. Javascript onScroll event

12. Help with Opera & onscroll event.

13. onscroll event

14. Detecting if onscroll events working / supported in Firefox

15. IE 8 - JavaScript onscroll event