P
PontiMax
My WinForm application hosts an AxWebBrowser control to
display HTML help files. Now I'm trying to capture all
mouse click events so that I can take the right steps if
the user clicks a certain hyperlink element.
I have followed the instructions from Microsoft
(http://support.microsoft.com/?kbid=312777) to accomplish
this but what happens is, if I add the onClick event
handler the browser becomes (partly) disabled: the context
menu doesn't work any more, the same holds for the
scrollbar (wheel functionality is disabled), I'm not able
to select text, etc.
Is there a problem with my code (see below)? Or is there a
better solution to this?
// Customize AxWebBrowser control
....
this.webBrowser.DocumentComplete += new
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler
(this.WebBrowser_DocumentComplete);
....
private void WebBrowser_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
mshtml.HTMLDocument oHTMLDocument;
oHTMLDocument = (mshtml.HTMLDocument)
this.webBrowser.Document;
mshtml.HTMLDocumentEvents2_Event oEvent;
oEvent = (mshtml.HTMLDocumentEvents2_Event) oHTMLDocument;
oEvent.onclick += new
mshtml.HTMLDocumentEvents2_onclickEventHandler(
this.ClickEventHandler);
}
private bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
Debug.WriteLine("Clicked on "+ e.srcElement.tagName);
return true;
}
Thank you very much for your help!
display HTML help files. Now I'm trying to capture all
mouse click events so that I can take the right steps if
the user clicks a certain hyperlink element.
I have followed the instructions from Microsoft
(http://support.microsoft.com/?kbid=312777) to accomplish
this but what happens is, if I add the onClick event
handler the browser becomes (partly) disabled: the context
menu doesn't work any more, the same holds for the
scrollbar (wheel functionality is disabled), I'm not able
to select text, etc.
Is there a problem with my code (see below)? Or is there a
better solution to this?
// Customize AxWebBrowser control
....
this.webBrowser.DocumentComplete += new
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler
(this.WebBrowser_DocumentComplete);
....
private void WebBrowser_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
mshtml.HTMLDocument oHTMLDocument;
oHTMLDocument = (mshtml.HTMLDocument)
this.webBrowser.Document;
mshtml.HTMLDocumentEvents2_Event oEvent;
oEvent = (mshtml.HTMLDocumentEvents2_Event) oHTMLDocument;
oEvent.onclick += new
mshtml.HTMLDocumentEvents2_onclickEventHandler(
this.ClickEventHandler);
}
private bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
Debug.WriteLine("Clicked on "+ e.srcElement.tagName);
return true;
}
Thank you very much for your help!