Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Web Browser Event Hook - Problems

Web Browser Event Hook - Problems

Scheduled Pinned Locked Moved C#
helphtml
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jacobb Michael
    wrote on last edited by
    #1

    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()
    
    O J 2 Replies Last reply
    0
    • J Jacobb Michael

      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()
      
      O Offline
      O Offline
      omizyurko
      wrote on last edited by
      #2

      I use AxSHDocVw.AxWebBrowser on a form. It work fine.

      1 Reply Last reply
      0
      • J Jacobb Michael

        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()
        
        J Offline
        J Offline
        j to the 4n
        wrote on last edited by
        #3

        Theres an microsoft article here, describing how to hook events on a webbrowser control: http://support.microsoft.com/kb/312777[^] ..tested and works fine

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups