how to save html file in VC++
hi,
i want to save a html file from my browser.
i have created my own browser and want to save the html file..
i have used ACTIVE X controls to make my own web browser(same as IE)..
it should be like that of SAVE AS option of IE..
plzzhelp..
If you already used shdocvw.dll COM server then a point to start is maybe the IHTMLDocument Interface. Use IWebBrowser2::Document Property to retreive an idispatch output pointer and do a queryinterface to IHTMLDocument2.
MSDN:
C++ programs can retrieve the Component Object Model (COM) interfaces IHTMLDocument, IHTMLDocument2, and IHTMLDocument3 by calling QueryInterface on the IDispatch received from this property.
Here some code in VB ( does the same you want ):
http://www.mvps.org/access/modules/mdl0062.htm
Use body property, get body interface and then use:
innerHTML Sets or retrieves the HTML between the start and end tags of the object.
innerText Sets or retrieves the text between the start and end tags of the object.
Bye
Martin
As i saw there is no directly way. You need to go throgh the elements of the webpages and put them into a stringlist and then save it. Thats one way.
Look into your project on disk. Is there any *.tlb and/or *.tlh file?
The look into *.tlh ( type library header ) and look into the interface class defeintions. There is no mehtod or property to retreive the html.
Maybe someone can help help you with a more easy solution. Maybe there is a trick ot there is a helper interface which does what you want. :-)
Bye
Martin
A very nice site for that is:
http://www.euromind.com/iedelphi/ie5tools/ieautomate.htmhttp://www.euromind.com/iedelphi/embeddedwb/utilities.htmIt is Pascal but really straight forward.
Pascal:
function SaveDocToFile(Doc: IDispatch; const Fname: string): HResult;
var
PFile: IPersistFile;
begin
PFile := Doc as IPersistFile;
Result := PFile.Save(StringToOleStr(FName), False);
end;
1. Get document interface pointer from your ActiveX control via document property. Look in definition file for that.
2. Make a cast to IPersistFile
3. Call Save method and you are done.
IHTMLDocument implements IPersistFile which is a general interface for loading and saving.
PUHHH. I'll go in the sun and have beer :-)
Bye
Martin
Your browser component. This is normal coz HTTP is session less protocol. Every time something changes and you want to save a browser makes a request also for every element in a web page.
Try to look at IE. It does the same.
Bye
Martin