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. How to output html of url into a RichTextBox in visual c++ 6

How to output html of url into a RichTextBox in visual c++ 6

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmltutorial
13 Posts 4 Posters 16 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.
  • M Offline
    M Offline
    method007
    wrote on last edited by
    #1

    Hi all. could any one show me how i can get the html of a perticuler url and place that html inside a textbox/editbox for further manipulation. I have done such think in visual basic 6 but i do not know that can be done in visual c++ 6. I be happy if some one show me how i can achive that.Thanks visual basic 6 method: RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)

    L D 2 Replies Last reply
    0
    • M method007

      Hi all. could any one show me how i can get the html of a perticuler url and place that html inside a textbox/editbox for further manipulation. I have done such think in visual basic 6 but i do not know that can be done in visual c++ 6. I be happy if some one show me how i can achive that.Thanks visual basic 6 method: RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Do a search on MSDN for CHttpConnection. That will lead to several other classes that wrap the WinInet API for making HTTP requests.

      "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
      Colin Angus Mackay in the C# forum

      led mike

      1 Reply Last reply
      0
      • M method007

        Hi all. could any one show me how i can get the html of a perticuler url and place that html inside a textbox/editbox for further manipulation. I have done such think in visual basic 6 but i do not know that can be done in visual c++ 6. I be happy if some one show me how i can achive that.Thanks visual basic 6 method: RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        method007 wrote:

        could any one show me how i can get the html of a perticuler url and place that html inside a textbox/editbox for further manipulation.

        Have you considered URLDownloadToFile()?


        "The largest fire starts but with the smallest spark." - David Crow

        "Judge not by the eye but by the heart." - Native American Proverb

        M 1 Reply Last reply
        0
        • D David Crow

          method007 wrote:

          could any one show me how i can get the html of a perticuler url and place that html inside a textbox/editbox for further manipulation.

          Have you considered URLDownloadToFile()?


          "The largest fire starts but with the smallest spark." - David Crow

          "Judge not by the eye but by the heart." - Native American Proverb

          M Offline
          M Offline
          method007
          wrote on last edited by
          #4

          man i am new to visual c++ .i be happy if u guys give me an example of how to use it. Just URLDownloadToFile() will not help me. You migh say msdn but that is not readable at all for starter.!! Furthermore, i do not want to download a url in file i just want to load its html code into a editbox for further process. -- modified at 13:19 Tuesday 11th July, 2006

          D M 2 Replies Last reply
          0
          • M method007

            man i am new to visual c++ .i be happy if u guys give me an example of how to use it. Just URLDownloadToFile() will not help me. You migh say msdn but that is not readable at all for starter.!! Furthermore, i do not want to download a url in file i just want to load its html code into a editbox for further process. -- modified at 13:19 Tuesday 11th July, 2006

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            method007 wrote:

            Just URLDownloadToFile() will not help me.

            Why not?

            method007 wrote:

            You migh say msdn but that is not readable at all for starter.!!

            Sure it is. I started using it some 15 years ago.

            method007 wrote:

            Furthermore, i do not want to download a url in file i just want to load its html code into a editbox for further process.

            This makes no sense. If you are wanting to edit the HTML, use URLDownloadToFile(). You can then plug the contents of the file into the edit control. Using the alternative IHTMLInterface would only complicate matters.


            "The largest fire starts but with the smallest spark." - David Crow

            "Judge not by the eye but by the heart." - Native American Proverb

            M 1 Reply Last reply
            0
            • M method007

              man i am new to visual c++ .i be happy if u guys give me an example of how to use it. Just URLDownloadToFile() will not help me. You migh say msdn but that is not readable at all for starter.!! Furthermore, i do not want to download a url in file i just want to load its html code into a editbox for further process. -- modified at 13:19 Tuesday 11th July, 2006

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

              HTML from where ? if it's from the web, David gave you a good starting point. else, if it's simple html text, just do a SetWindowText of the HTML code to the CEditBox; but it will not be formatted.


              Maximilien Lincourt Your Head A Splode - Strong Bad

              M 1 Reply Last reply
              0
              • D David Crow

                method007 wrote:

                Just URLDownloadToFile() will not help me.

                Why not?

                method007 wrote:

                You migh say msdn but that is not readable at all for starter.!!

                Sure it is. I started using it some 15 years ago.

                method007 wrote:

                Furthermore, i do not want to download a url in file i just want to load its html code into a editbox for further process.

                This makes no sense. If you are wanting to edit the HTML, use URLDownloadToFile(). You can then plug the contents of the file into the edit control. Using the alternative IHTMLInterface would only complicate matters.


                "The largest fire starts but with the smallest spark." - David Crow

                "Judge not by the eye but by the heart." - Native American Proverb

                M Offline
                M Offline
                method007
                wrote on last edited by
                #7

                my whole intention is to extract data from a html page so it would be easier to load the html instead of the file !! i have done this in visual basic 6 but i need to do it for a project that is visual c++ 6 and so far i just get unrleated answer and no example!!! i think this the nature of visual c++ programers unlicke visual basic programmers!!

                D 1 Reply Last reply
                0
                • M method007

                  my whole intention is to extract data from a html page so it would be easier to load the html instead of the file !! i have done this in visual basic 6 but i need to do it for a project that is visual c++ 6 and so far i just get unrleated answer and no example!!! i think this the nature of visual c++ programers unlicke visual basic programmers!!

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  method007 wrote:

                  ...so far i just get unrleated answer and no example!!!

                  I've given you more than enough information to solve your problem. As a matter of fact, you've been given several solutions to the same problem. That's very gratuitous in my book. This retrieves all of the <FONT> elements: IDispatch pDisp2 = m_ctrlBrowser.GetDocument(); // m_ctrlBrowser is a CWebBrowser2 object pDisp2->QueryInterface(IID_IHTMLDocument2, (void **) &ptrHTMLDocument); // ptrHTMLDocument is a IHTMLDocument2* BSTR pBURL = SysAllocStringByteLen(NULL, 1024); ptrHTMLDocument->get_URL(&pBURL); ptrHTMLDocument->get_all(&ptrHTMLElements); // ptrHTMLElements is a IHTMLElementCollection* ptrHTMLElements->get_length(&lElements); // lElements is a long VARIANT varName; varName.vt = VT_BYREF | VT_I1; varName.pcVal = "FONT"; VARIANT varIndex; varIndex.vt = VT_I4; varIndex.lVal = 1; ptrHTMLElements->item(varName, varIndex, &pDisp3); // pDisp3 is a IDispatch pDisp3->QueryInterface(IID_IHTMLElement, (void **) &ptrHTMLElement); // ptrHTMLElement is a IHTMLElement* ptrHTMLElement->get_innerHTML(&pBURL); ptrHTMLDocument->Release();


                  "The largest fire starts but with the smallest spark." - David Crow

                  "Judge not by the eye but by the heart." - Native American Proverb

                  M 1 Reply Last reply
                  0
                  • M Maximilien

                    HTML from where ? if it's from the web, David gave you a good starting point. else, if it's simple html text, just do a SetWindowText of the HTML code to the CEditBox; but it will not be formatted.


                    Maximilien Lincourt Your Head A Splode - Strong Bad

                    M Offline
                    M Offline
                    method007
                    wrote on last edited by
                    #9

                    Maximilien . i want first get html code of a specified url then use that to extract specific data from it. i want to load that html in textbox first then maniuplate it!!

                    1 Reply Last reply
                    0
                    • D David Crow

                      method007 wrote:

                      ...so far i just get unrleated answer and no example!!!

                      I've given you more than enough information to solve your problem. As a matter of fact, you've been given several solutions to the same problem. That's very gratuitous in my book. This retrieves all of the <FONT> elements: IDispatch pDisp2 = m_ctrlBrowser.GetDocument(); // m_ctrlBrowser is a CWebBrowser2 object pDisp2->QueryInterface(IID_IHTMLDocument2, (void **) &ptrHTMLDocument); // ptrHTMLDocument is a IHTMLDocument2* BSTR pBURL = SysAllocStringByteLen(NULL, 1024); ptrHTMLDocument->get_URL(&pBURL); ptrHTMLDocument->get_all(&ptrHTMLElements); // ptrHTMLElements is a IHTMLElementCollection* ptrHTMLElements->get_length(&lElements); // lElements is a long VARIANT varName; varName.vt = VT_BYREF | VT_I1; varName.pcVal = "FONT"; VARIANT varIndex; varIndex.vt = VT_I4; varIndex.lVal = 1; ptrHTMLElements->item(varName, varIndex, &pDisp3); // pDisp3 is a IDispatch pDisp3->QueryInterface(IID_IHTMLElement, (void **) &ptrHTMLElement); // ptrHTMLElement is a IHTMLElement* ptrHTMLElement->get_innerHTML(&pBURL); ptrHTMLDocument->Release();


                      "The largest fire starts but with the smallest spark." - David Crow

                      "Judge not by the eye but by the heart." - Native American Proverb

                      M Offline
                      M Offline
                      method007
                      wrote on last edited by
                      #10

                      DavidCrow thank u for u code. But i want the get the whole html of a specific url and place it in a textbox just like i showed u in visual basic 6. I do not want to retrive font elements!!!

                      D 1 Reply Last reply
                      0
                      • M method007

                        DavidCrow thank u for u code. But i want the get the whole html of a specific url and place it in a textbox just like i showed u in visual basic 6. I do not want to retrive font elements!!!

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        method007 wrote:

                        But i want the get the whole html of a specific url and place it in a textbox...

                        Then do as I've already suggested. Use URLDownloadToFile() to download the HTML to some temporary file. You can then plug the contents of the file into the edit control. It's a very simple procedure.


                        "The largest fire starts but with the smallest spark." - David Crow

                        "Judge not by the eye but by the heart." - Native American Proverb

                        M 1 Reply Last reply
                        0
                        • D David Crow

                          method007 wrote:

                          But i want the get the whole html of a specific url and place it in a textbox...

                          Then do as I've already suggested. Use URLDownloadToFile() to download the HTML to some temporary file. You can then plug the contents of the file into the edit control. It's a very simple procedure.


                          "The largest fire starts but with the smallest spark." - David Crow

                          "Judge not by the eye but by the heart." - Native American Proverb

                          M Offline
                          M Offline
                          method007
                          wrote on last edited by
                          #12

                          In visual basic it is online code and but i have no idea how to do it in visual c++ 6. could u show me how ?Thanks

                          D 1 Reply Last reply
                          0
                          • M method007

                            In visual basic it is online code and but i have no idea how to do it in visual c++ 6. could u show me how ?Thanks

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #13

                            method007 wrote:

                            ...i have no idea how to do it in visual c++ 6. could u show me how ?

                            See here. Once you have a file, you can then open the file using any number of methods (e.g., CFile, FILE*, CreateFile()).


                            "The largest fire starts but with the smallest spark." - David Crow

                            "Judge not by the eye but by the heart." - Native American Proverb

                            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