Einzelnen Beitrag anzeigen

Benutzerbild von Union
Union

Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.487 Beiträge
 
Delphi 7 Enterprise
 
#13

AW: Größe einer Website

  Alt 16. Sep 2011, 21:48
Ich habs. Zwar ohne Exception Handling und JPeg aber es funktioniert:
Delphi-Quellcode:
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;
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all
  Mit Zitat antworten Zitat