Save web page
-
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.
-
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.
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] -
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] -
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...........
How about using
CHtmlView::GetSource
and writing it to a file.«_Superman_»
I love work. It gives me something to do between weekends. -
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...........
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
-
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
Pallini , your solution goes fine :
pDispl = <>.GetHtmlDocument();
Thank you !!!
-
Pallini , your solution goes fine :
pDispl = <>.GetHtmlDocument();
Thank you !!!
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]