Web Browser Event Hook - Problems
-
Hi all, I have some issues on Registering event, If you have any idea on my implementation please help me …
private SHDocVw.InternetExplorer browser;
HTMLDocument document;
HTMLDocumentEvents2_Event DocEvents;This Event Fires well, when ever I click on any link the event is fired no issue on that. But when I click on the Text box the focus losts.
browser = (SHDocVw.InternetExplorer)pDisp;
DocEvents = (mshtml.HTMLDocumentEvents2_Event)document;
DocEvents.onclick += new HTMLDocumentEvents2_onclickEventHandler(DocEvents_onclick);To over come this issues I have just implemented from one of the articles like bellow
// The delegate:
public delegate void DHTMLEvent(IHTMLEventObj e);/// /// Generic Event handler for HTML DOM objects. /// Handles a basic event object which receives an IHTMLEventObj which /// applies to all document events raised. /// \[ComVisible(false)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.HTMLDocument Document; public DHTMLEventHandler(mshtml. HTMLDocument doc) { this.Document = doc; } \[DispId(0)\] public void Call() { Handler(Document.parentWindow.@event); } }
browser = (SHDocVw.InternetExplorer)pDisp;
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)browser.Document;
DHTMLEventHandler Handler = new DHTMLEventHandler(doc);
Handler.Handler += new DHTMLEvent(this.myCallback);
doc.onclick = Handler;but it shows the bello error. Ambiguity between 'mshtml.DispHTMLDocument.onclick' and 'mshtml.HTMLDocumentEvents_Event.onclick So I have changed from mshtml.HTMLDocument to mshtml.DispHTMLDocument Now there is no compilation error but while excecuting it shows the bellow error System.NotImplementedException , NotImplemented “\r\n” Somewhat I got the information that we have to use mshtml. IHTMLDocument2 So I have used as bellow
public delegate void DHTMLEvent(mshtml.IHTMLEventObj e);
\[ComVisible(true)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.IHTMLDocument2 Document; public DHTMLEventHandler(mshtml.IHTMLDocument2 doc) { this.Document = doc; } \[DispId(0)\] public void Call()
-
Hi all, I have some issues on Registering event, If you have any idea on my implementation please help me …
private SHDocVw.InternetExplorer browser;
HTMLDocument document;
HTMLDocumentEvents2_Event DocEvents;This Event Fires well, when ever I click on any link the event is fired no issue on that. But when I click on the Text box the focus losts.
browser = (SHDocVw.InternetExplorer)pDisp;
DocEvents = (mshtml.HTMLDocumentEvents2_Event)document;
DocEvents.onclick += new HTMLDocumentEvents2_onclickEventHandler(DocEvents_onclick);To over come this issues I have just implemented from one of the articles like bellow
// The delegate:
public delegate void DHTMLEvent(IHTMLEventObj e);/// /// Generic Event handler for HTML DOM objects. /// Handles a basic event object which receives an IHTMLEventObj which /// applies to all document events raised. /// \[ComVisible(false)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.HTMLDocument Document; public DHTMLEventHandler(mshtml. HTMLDocument doc) { this.Document = doc; } \[DispId(0)\] public void Call() { Handler(Document.parentWindow.@event); } }
browser = (SHDocVw.InternetExplorer)pDisp;
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)browser.Document;
DHTMLEventHandler Handler = new DHTMLEventHandler(doc);
Handler.Handler += new DHTMLEvent(this.myCallback);
doc.onclick = Handler;but it shows the bello error. Ambiguity between 'mshtml.DispHTMLDocument.onclick' and 'mshtml.HTMLDocumentEvents_Event.onclick So I have changed from mshtml.HTMLDocument to mshtml.DispHTMLDocument Now there is no compilation error but while excecuting it shows the bellow error System.NotImplementedException , NotImplemented “\r\n” Somewhat I got the information that we have to use mshtml. IHTMLDocument2 So I have used as bellow
public delegate void DHTMLEvent(mshtml.IHTMLEventObj e);
\[ComVisible(true)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.IHTMLDocument2 Document; public DHTMLEventHandler(mshtml.IHTMLDocument2 doc) { this.Document = doc; } \[DispId(0)\] public void Call()
-
Hi all, I have some issues on Registering event, If you have any idea on my implementation please help me …
private SHDocVw.InternetExplorer browser;
HTMLDocument document;
HTMLDocumentEvents2_Event DocEvents;This Event Fires well, when ever I click on any link the event is fired no issue on that. But when I click on the Text box the focus losts.
browser = (SHDocVw.InternetExplorer)pDisp;
DocEvents = (mshtml.HTMLDocumentEvents2_Event)document;
DocEvents.onclick += new HTMLDocumentEvents2_onclickEventHandler(DocEvents_onclick);To over come this issues I have just implemented from one of the articles like bellow
// The delegate:
public delegate void DHTMLEvent(IHTMLEventObj e);/// /// Generic Event handler for HTML DOM objects. /// Handles a basic event object which receives an IHTMLEventObj which /// applies to all document events raised. /// \[ComVisible(false)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.HTMLDocument Document; public DHTMLEventHandler(mshtml. HTMLDocument doc) { this.Document = doc; } \[DispId(0)\] public void Call() { Handler(Document.parentWindow.@event); } }
browser = (SHDocVw.InternetExplorer)pDisp;
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)browser.Document;
DHTMLEventHandler Handler = new DHTMLEventHandler(doc);
Handler.Handler += new DHTMLEvent(this.myCallback);
doc.onclick = Handler;but it shows the bello error. Ambiguity between 'mshtml.DispHTMLDocument.onclick' and 'mshtml.HTMLDocumentEvents_Event.onclick So I have changed from mshtml.HTMLDocument to mshtml.DispHTMLDocument Now there is no compilation error but while excecuting it shows the bellow error System.NotImplementedException , NotImplemented “\r\n” Somewhat I got the information that we have to use mshtml. IHTMLDocument2 So I have used as bellow
public delegate void DHTMLEvent(mshtml.IHTMLEventObj e);
\[ComVisible(true)\] public class DHTMLEventHandler { public DHTMLEvent Handler; mshtml.IHTMLDocument2 Document; public DHTMLEventHandler(mshtml.IHTMLDocument2 doc) { this.Document = doc; } \[DispId(0)\] public void Call()
Theres an microsoft article here, describing how to hook events on a webbrowser control: http://support.microsoft.com/kb/312777[^] ..tested and works fine