uses SHDocVW, MSHTML,
ActiveX;
procedure MakeWebShot(Browser : TWebBrowser; AFileName :
string);
var
sr : TRect;
Document : IHTMLDocument2;
Body : IHTMLElement2;
Bitmap : TBitmap;
ViewObject : IViewObject;
begin
Document := Browser.Document
as IHTMLDocument2;
Body := Document.Body
as IHTMLElement2;
// Der Browser darf dafür NICHT alClient sein, sonst hat es keine Auswirkung!
Document.body.style.overflow := '
hidden';
sr := Rect(0, 0, Body.scrollWidth, Body.scrollHeight);
Browser.Width := sr.Right;
Browser.Height := sr.Bottom;
Document.QueryInterface(IViewObject, ViewObject);
Bitmap := TBitmap.Create;
Bitmap.Width := sr.Right;
Bitmap.Height := sr.Bottom;
ViewObject.Draw(DVASPECT_CONTENT, 1,
nil,
nil, Application.Handle, Bitmap.Canvas.Handle, @sr,
nil,
nil, 0);
Bitmap.SaveToFile(AFileName);
Bitmap.Free;
end;