PC Review


Reply
Thread Tools Rate Thread

Capturing AxWebBrowser events

 
 
PontiMax
Guest
Posts: n/a
 
      6th Aug 2003
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!
 
Reply With Quote
 
 
 
 
James Hancock
Guest
Posts: n/a
 
      6th Aug 2003
The only way to work this is to inherit from the base class/interface and
impliment stubs for each event in the interface.

If you have Vs.net 2003 you'll be treated to the whole thing being done for
you, if not you have to do them manually.

Implimenting the events themselves causes the control to freak out and die
as you describe.

James Hancock

"PontiMax" <(E-Mail Removed)> wrote in message
news:078b01c35bf3$d7b2b6a0$(E-Mail Removed)...
> 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!



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: AxWebBrowser events not firing Walter Wang [MSFT] Microsoft C# .NET 0 28th Dec 2006 06:38 AM
AxWebBrowser events not firing -- IE 7's fault? =?Utf-8?B?Um9iS2lubmV5MQ==?= Microsoft C# .NET 0 19th Sep 2006 11:17 PM
AxSHDocVw.AxWebBrowser events GS Microsoft VB .NET 3 10th Sep 2006 07:56 AM
AxWebBrowser is not firing events in production gatzo Microsoft Dot NET Framework Forms 0 14th Oct 2004 02:03 PM
Re: axWebBrowser & Events Champika Nirosh Microsoft C# .NET 0 28th Jul 2003 07:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:05 PM.