handling onscroll event of WebBrowser (repost)

handling onscroll event of WebBrowser (repost)

Post by Jocke » Sun, 20 Aug 2006 01:28:48


I'll try reposting this message with the hope someone can help me with
this issue.
PS: is this the right newsgroup for this question?

---

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