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 / C++ / MFC
  4. Using MFC to host web browser control

Using MFC to host web browser control

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmltutorialquestion
8 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.
  • R Offline
    R Offline
    RobJones
    wrote on last edited by
    #1

    Hello, I have created a Dialog App and put a Active X Web browser object into the App. I'm having problems with continuously reporting the current url being visited into a edit box. If I create an event to put the info into the edit box this works fine (example: I created a button that runs the code listed below. This posts the information fine). I would like to continuously show the url being displayed. In this article listed below provided by Microsoft it says to put the code listed at the bottom of this page into the "initialization process", this doesn't seem to work. I have put the code into BOOL CBHCBrowserDlg::OnInitDialog() Microsoft article: If the current location is an HTML page on the World Wide Web, you can use the IWebBrowser2::get_LocationURL methods to retrieve the full path of the folder or file. If you want this information displayed continuously, add the following code to the initialization process. If you want it displayed only when an event occurs, add the code to an event handler. The following example uses IWebBrowser2::get_LocationURL to retrieve location information and display it in an edit box. //CWebBrowser2 m_browser - to access the WebBrowser control //CEdit m_edit - to access the edit control CString string1; string1 = m_browser.GetLocationName(); m_edit.SetWindowText(string1); Any Ideas? THANKS,

    M C 2 Replies Last reply
    0
    • R RobJones

      Hello, I have created a Dialog App and put a Active X Web browser object into the App. I'm having problems with continuously reporting the current url being visited into a edit box. If I create an event to put the info into the edit box this works fine (example: I created a button that runs the code listed below. This posts the information fine). I would like to continuously show the url being displayed. In this article listed below provided by Microsoft it says to put the code listed at the bottom of this page into the "initialization process", this doesn't seem to work. I have put the code into BOOL CBHCBrowserDlg::OnInitDialog() Microsoft article: If the current location is an HTML page on the World Wide Web, you can use the IWebBrowser2::get_LocationURL methods to retrieve the full path of the folder or file. If you want this information displayed continuously, add the following code to the initialization process. If you want it displayed only when an event occurs, add the code to an event handler. The following example uses IWebBrowser2::get_LocationURL to retrieve location information and display it in an edit box. //CWebBrowser2 m_browser - to access the WebBrowser control //CEdit m_edit - to access the edit control CString string1; string1 = m_browser.GetLocationName(); m_edit.SetWindowText(string1); Any Ideas? THANKS,

      M Offline
      M Offline
      Masaaki Onishi
      wrote on last edited by
      #2

      Hello, the codegurus around the world.;) First of all, this is my guess.:cool: 1) IWebBrowser2 may have some Event function to let us know that now updated html display is completed something like that. So, if this exists, you put get_LocationURL. 2) Try to use Timer or Thread function to always moinitor get_LocationURL. And if URL is updated from old one, update this URL to edit box. :confused: Have a nice day! -Masaaki Onishi-

      1 Reply Last reply
      0
      • R RobJones

        Hello, I have created a Dialog App and put a Active X Web browser object into the App. I'm having problems with continuously reporting the current url being visited into a edit box. If I create an event to put the info into the edit box this works fine (example: I created a button that runs the code listed below. This posts the information fine). I would like to continuously show the url being displayed. In this article listed below provided by Microsoft it says to put the code listed at the bottom of this page into the "initialization process", this doesn't seem to work. I have put the code into BOOL CBHCBrowserDlg::OnInitDialog() Microsoft article: If the current location is an HTML page on the World Wide Web, you can use the IWebBrowser2::get_LocationURL methods to retrieve the full path of the folder or file. If you want this information displayed continuously, add the following code to the initialization process. If you want it displayed only when an event occurs, add the code to an event handler. The following example uses IWebBrowser2::get_LocationURL to retrieve location information and display it in an edit box. //CWebBrowser2 m_browser - to access the WebBrowser control //CEdit m_edit - to access the edit control CString string1; string1 = m_browser.GetLocationName(); m_edit.SetWindowText(string1); Any Ideas? THANKS,

        C Offline
        C Offline
        Colin J Davies
        wrote on last edited by
        #3

        Place the code CString string1; string1 = m_browser.GetLocationName(); m_edit.SetWindowText(string1); in the DocumentComplete Returned Message for your WebBrowser Regardz Colin Davies

        R 1 Reply Last reply
        0
        • C Colin J Davies

          Place the code CString string1; string1 = m_browser.GetLocationName(); m_edit.SetWindowText(string1); in the DocumentComplete Returned Message for your WebBrowser Regardz Colin Davies

          R Offline
          R Offline
          RobJones
          wrote on last edited by
          #4

          Thanks for all the help! I found a event OnDownloadComplete. Everything works great. Thanks.. Rob

          C 1 Reply Last reply
          0
          • R RobJones

            Thanks for all the help! I found a event OnDownloadComplete. Everything works great. Thanks.. Rob

            C Offline
            C Offline
            Colin J Davies
            wrote on last edited by
            #5

            Note: OnDownloadComplete fires for every object on a web page eg (jpgs or gifs etc or even frames) OnDocumentComplete fires for the whole Page. Regardz Colin

            R 1 Reply Last reply
            0
            • C Colin J Davies

              Note: OnDownloadComplete fires for every object on a web page eg (jpgs or gifs etc or even frames) OnDocumentComplete fires for the whole Page. Regardz Colin

              R Offline
              R Offline
              RobJones
              wrote on last edited by
              #6

              I didn't see any OnDocumentComplete event for the Microsoft Web Browser Active X object.. :confused: Rob Jones

              C 1 Reply Last reply
              0
              • R RobJones

                I didn't see any OnDocumentComplete event for the Microsoft Web Browser Active X object.. :confused: Rob Jones

                C Offline
                C Offline
                Colin J Davies
                wrote on last edited by
                #7

                Rob Using The Class Wizard its the 11th event down for a browser control added as a member variable, I just checked and it is there on my VC+ 6.00 Regardz Colin

                R 1 Reply Last reply
                0
                • C Colin J Davies

                  Rob Using The Class Wizard its the 11th event down for a browser control added as a member variable, I just checked and it is there on my VC+ 6.00 Regardz Colin

                  R Offline
                  R Offline
                  RobJones
                  wrote on last edited by
                  #8

                  You are correct. I looked there like 5 times before, don't know how I missed it. Weird. Thanks for all your help. I did use that event and added the code to this event. Everything works great! Thanks again,:cool: Rob Jones

                  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