Wow,
Thanks for commenting on this...
But look, what you suggest is working, but not for what I want to do...
It's working for the active windows, this means that I will not be able to
do something else while catching stuff...
And most of all, it does not work for a hidden windows...
So...thanks for your time, I appreciate the effort.
Bests regards.
John.
But I found how to do since the time. Some cool guys did know some links
others agreed to share there great knowledge with me.
So here it is :
Of course it's delphi stuff
procedure generateJPEGfromBrowser(browser: iWebBrowser2;
jpegFQFilename: string; srcHeight: Integer; srcWidth: Integer;
tarHeight: Integer; tarWidth: Integer);
var
sourceDrawRect: TRect;
targetDrawRect: TRect;
sourceBitmap: TBitmap;
targetBitmap: TBitmap;
jpeg: TJPEGImage;
viewObject: IViewObject;
begin
sourceBitmap := TBitmap.Create;
targetBitmap := TBitmap.Create;
jpeg := TJPEGImage.Create;
try
try
sourceDrawRect := Rect(0, 0, srcWidth, srcHeight);
sourceBitmap.Width := srcWidth;
sourceBitmap.Height := srcHeight;
viewObject := browser as IViewObject;
if viewObject = nil then
exit;
OleCheck(viewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, Application.Handle,
sourceBitmap.Canvas.Handle, @sourceDrawRect, nil, nil, 0));
// Resize the src bitmap to the target bitmap
targetDrawRect := Rect(0, 0, tarWidth, tarHeight);
targetBitmap.Height := tarHeight;
targetBitmap.Width := tarWidth;
targetBitmap.Canvas.StretchDraw(targetDrawRect, sourceBitmap);
// Create a JPEG from the Bitmap and save it
jpeg.Assign(targetBitmap);
//makeFileWriteable(jpegFQFilename);
jpeg.SaveToFile(jpegFQFilename);
finally
jpeg.free;
sourceBitmap.free;
targetBitmap.free;
end;
except
// Error Code
end;
end;
procedure TFRM_tree_import.Button2Click(Sender: TObject);
var
ViewObject: IViewObject;
sourceDrawRect: TRect;
begin
if EmbeddedWB1.Document <> nil then
try
EmbeddedWB1.Document.QueryInterface(IViewObject, ViewObject);
if ViewObject <> nil then
try
sourceDrawRect := Rect(0, 0, EmbeddedWB1.Width, EmbeddedWB1.Height);
OleCheck(ViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, Self.Handle,
image1.Canvas.Handle, @sourceDrawRect, nil, nil, 0));
finally
ViewObject._Release;
end;
except end;
end;