1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| uses ActiveX,SHDocVw,Windows,Graphics;
procedure CopyWebToCanvas(AWebBrowser:TWebBrowser;ACanvas:TCanvas;HandlePeripheriqueCible:HDC=0);
var
ViewObject: IViewObject;
sourceDrawRect: TRect;
Temp,Dest:TBitmap;
begin
if AWebBrowser.Document <> nil then
try
Dest:=TBitmap.Create;
Dest.PixelFormat:=pf24bit;
Temp:=TBitmap.Create;
Temp.PixelFormat:=pf24bit;
Temp.Width:=AWebBrowser.Width;
Temp.Height:=AWebBrowser.Height;
AWebBrowser.Document.QueryInterface(IViewObject, ViewObject);
if ViewObject <> nil then
try
sourceDrawRect := Rect(0, 0, Temp.Width, Temp.Height);
ViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, HandlePeripheriqueCible,
Temp.Canvas.Handle, @sourceDrawRect, nil, nil, 0);
finally
ViewObject._Release;
Dest.Width:=Temp.Width-GetSystemMetrics(SM_CXVSCROLL);
Dest.Height:=Temp.Height;
BitBlt(Dest.Canvas.Handle,0,0,Dest.Width,Dest.Height,Temp.Canvas.Handle,0,0,SrcCopy);
ACanvas.Draw(0,0,Dest);
Temp.Free;
Dest.Free;
end;
except
end;
end; |
Partager