How to output html of url into a RichTextBox in visual c++ 6
-
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)
-
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)
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# forumled mike
-
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)
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
-
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
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
-
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
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 alternativeIHTMLInterface
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
-
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
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
-
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 alternativeIHTMLInterface
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
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!!
-
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!!
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
-
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
-
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
-
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!!!
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
-
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
-
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
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