1. Purpose
In codeproject, we can see that someone has done this. I made a slight modification and made it into a command line. The usage is as follows:
Iesnap.exe URL filename
Used to capture the web of a URL pair and save the web in filename.
URL: the URL
Filename: Save the file name
2. Ideas
Webbrowser control and mshtml are mainly used.
A. Create webbrowser Control
B. Obtain the iwebbrowser2 interface from webbrowser control and use iwebbrowser2: navigate2 to access the URL.
C. Obtain ihtmlelementrender (webbrowser-> ihtmldocument2-> ihtmlelement-> ihtmlelementrender) and use the drawtodc interface to obtain the page content corresponding to the URL.
D. Use the image of GDI to save it to filename.
3.
Let's take a look at the original article for better answers.
The article I read: Capture an HTML document as an image
Another article in C #: Image Capture Whole Web Page using C #
4. Problem
A. The DocumentComplete event occurs when each element on the corresponding page of the URL is downloaded. Therefore, (you do not know which event is the download completed on the entire page :/
B. Now we use MFC to create WebBrowser Control. I don't know how to create this Control in Win32 Application.
C. I don't know how to get the size of the entire page. Now I can only save a part of the page :(
I already know how to do this.
The scrollWidth & scrollHeight of IHTMLElement2 is implemented by adding scrollLeft & scrollTop, but I don't know why. The put_scrollTop & put_scrollLeft functions seem wrong and can only be intercepted on some pages. :( I don't know why.
Code can be downloaded here: http://www.cppblog.com/Files/bigsml/iesnapshot.zip