uses ActiveX;
Function WebBrowserScreenShot(
const wb: TWebBrowser):TBitmap ;
var
viewObject : IViewObject;
r : TRect;
begin
Result := TBitmap.Create;
if wb.Document <>
nil then
begin
wb.Document.QueryInterface(IViewObject, viewObject) ;
if Assigned(viewObject)
then
try
r := Rect(0, 0, wb.Width, wb.Height) ;
Result.Height := wb.Height;
Result.Width := wb.Width;
viewObject.Draw(DVASPECT_CONTENT, 1,
nil,
nil, Application.Handle, Result.Canvas.Handle, @r,
nil,
nil, 0) ;
finally
viewObject._Release;
end;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
Bitmap,webbmp:TBitmap;
begin
Bitmap:=GetFormImage;
webbmp := WebBrowserScreenShot(webBrowser1);
Bitmap.Canvas.Draw(webBrowser1.Left,WebBrowser1.top,webbmp);
try
Clipboard.Assign(Bitmap);
finally
Bitmap.Free;
webbmp.Free;
// MessageBox-Code
//
case messageBox(
handle,
'
Eine Hardcopy wurde in die Zwischenablage kopiert.',
'
Info',
0
OR 0
OR MB_DEFBUTTON1)
of
IDOK:
begin
// Knopf "Ok" gedrückt
end;
end;
// Ende MessageBox - Code
end;
end;