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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Save web page

Save web page

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
7 Posts 4 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.
  • V Offline
    V Offline
    VVVimal
    wrote on last edited by
    #1

    Visual C++ Solution Accomplishing this task from a Visual C++ host is very straightforward. You can use an IWebBrowser2 interface to call the QueryInterface method for the IHTMLDocument2 interface. After you obtain a pointer to the document, then call QueryInterface for the IPersistFile interface. After you obtain this interface pointer, you can call the save method to save the file to disk. HRESULT hr = E_FAIL; IDispatch* pDisp = NULL; IHTMLDocument2* pDoc = NULL; pDisp = m_webOC.GetDocument(); if(SUCCEEDED(hr = pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc))) { IPersistFile* pFile = NULL; if(SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile,(void**)&pFile))) { LPCOLESTR file = L"c:\\test1.htm"; pFile->Save(file,TRUE); } } Hi all I have seen this ariticle in MSDN. In that i don't know m_webOC belongs to which object. If so how to create that object.

    CPalliniC 1 Reply Last reply
    0
    • V VVVimal

      Visual C++ Solution Accomplishing this task from a Visual C++ host is very straightforward. You can use an IWebBrowser2 interface to call the QueryInterface method for the IHTMLDocument2 interface. After you obtain a pointer to the document, then call QueryInterface for the IPersistFile interface. After you obtain this interface pointer, you can call the save method to save the file to disk. HRESULT hr = E_FAIL; IDispatch* pDisp = NULL; IHTMLDocument2* pDoc = NULL; pDisp = m_webOC.GetDocument(); if(SUCCEEDED(hr = pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc))) { IPersistFile* pFile = NULL; if(SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile,(void**)&pFile))) { LPCOLESTR file = L"c:\\test1.htm"; pFile->Save(file,TRUE); } } Hi all I have seen this ariticle in MSDN. In that i don't know m_webOC belongs to which object. If so how to create that object.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Form the article "How To Programmatically Save an HTML Page to Disk":

      As a Web browser control host, or an application that is automating Internet Explorer, you may find it useful to be able to programmatically save the currently loaded document to disk without user intervention.

      So, does your application host a Web Browser control? Or, are you automating I.E.? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      V 1 Reply Last reply
      0
      • CPalliniC CPallini

        Form the article "How To Programmatically Save an HTML Page to Disk":

        As a Web browser control host, or an application that is automating Internet Explorer, you may find it useful to be able to programmatically save the currently loaded document to disk without user intervention.

        So, does your application host a Web Browser control? Or, are you automating I.E.? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        V Offline
        V Offline
        VVVimal
        wrote on last edited by
        #3

        I am not using Webrowser control But it is an SDI appllication with CHtmlView..... I just want to save a web page and read them back. Could u give any information on this...........

        _ CPalliniC 2 Replies Last reply
        0
        • V VVVimal

          I am not using Webrowser control But it is an SDI appllication with CHtmlView..... I just want to save a web page and read them back. Could u give any information on this...........

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          How about using CHtmlView::GetSource and writing it to a file.

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          1 Reply Last reply
          0
          • V VVVimal

            I am not using Webrowser control But it is an SDI appllication with CHtmlView..... I just want to save a web page and read them back. Could u give any information on this...........

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            You may follow Superman's suggestion or replace

            pDisp = m_webOC.GetDocument();

            with

            pDispl = <YourCHtmlViewName>.GetHtmlDocument();

            :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            modified on Monday, September 20, 2010 6:46 AM

            In testa che avete, signor di Ceprano?

            M 1 Reply Last reply
            0
            • CPalliniC CPallini

              You may follow Superman's suggestion or replace

              pDisp = m_webOC.GetDocument();

              with

              pDispl = <YourCHtmlViewName>.GetHtmlDocument();

              :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              modified on Monday, September 20, 2010 6:46 AM

              M Offline
              M Offline
              mesajflaviu
              wrote on last edited by
              #6

              Pallini , your solution goes fine :

              pDispl = <>.GetHtmlDocument();

              Thank you !!!

              CPalliniC 1 Reply Last reply
              0
              • M mesajflaviu

                Pallini , your solution goes fine :

                pDispl = <>.GetHtmlDocument();

                Thank you !!!

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                You are welcome. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                In testa che avete, signor di Ceprano?

                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