![]() |
Image from TWebBrowser -> TPicture
hi!
i found a c# solution but i have no idea how to do this in delphi.
Code:
IHTMLDocument2 doc = (IHTMLDocument2)wb1.Document.DomDocument;
IHTMLControlRange imgRange = (IHTMLControlRange)((HTMLBody)doc.body).createControlRange(); foreach (IHTMLImgElement img in doc.images) { if (img.nameProp.Contains('sometag')) { IHTMLElementRenderFixed render = (IHTMLElementRenderFixed)img; Bitmap bmp = new Bitmap(img.width, img.height); Graphics g = Graphics.FromImage(bmp); IntPtr hdc = g.GetHdc(); render.DrawToDC(hdc); g.ReleaseHdc(hdc); ImageBmp = bmp; break; } } } |
AW: Image from TWebBrowser -> TPicture
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; |
AW: Image from TWebBrowser -> TPicture
// Whoops :)
|
AW: Image from TWebBrowser -> TPicture
Yes Mr. Joey Smith
|
AW: Image from TWebBrowser -> TPicture
für alle die den jetzt nicht verstanden haben:
![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz