Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
Delphi 10 Seattle Enterprise
|
AW: Image from TWebBrowser -> TPicture
18. Nov 2012, 22:59
It is nearly exact the same in delphi
Delphi-Quellcode:
var
doc : IHTMLDocument2;
imgRange : IHTMLControlRange;
img : IHTMLImgElement;
render : IHTMLElementRender;
bmp : TBitmap;
_hdc : HDC;
img_NameProp : string;
img_idx : Integer;
begin
doc := Browser_WebBrowser.Document as IHTMLDocument2;
imgRange := ( doc.body as HTMLBody ).createControlRange as IHTMLControlRange;
for img_idx := 0 to Pred( doc.images.length ) do
begin
img := doc.images.item( img_idx, EmptyParam ) as IHTMLImgElement;
img_NameProp := Utf8ToAnsi( UTF8Encode( img.nameProp ) );
if ContainsText( img_NameProp, 'sometag' )
then
begin
render := ( img as IHTMLElementRender );
bmp := TBitmap.Create;
try
bmp.Width := img.Width;
bmp.Height := img.Height;
_hdc := bmp.Canvas.Handle;
render.DrawToDC( _hdc );
Image1.Picture.Assign( bmp );
finally
bmp.Free;
end;
break;
end;
end;
end;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
Geändert von Sir Rufo (18. Nov 2012 um 23:09 Uhr)
|