By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,660 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,660 IT Pros & Developers. It's quick & easy.

handling onscroll event of WebBrowser (repost)

P: n/a
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.
>From MSDN it seems that IHTMLWindow2.onscroll property is the way to go
http://msdn.microsoft.com/workshop/b...ence/ifaces/wi...
http://msdn.microsoft.com/workshop/a...ce/events/onsc...
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(we bBrowser_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

Aug 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.