Создаю отчет в виде html-странички. Вот таким образом гружу html-код в TWebBrowser:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, ActiveX, StdCtrls;
type TForm1 = class(TForm) WebBrowser1: TWebBrowser; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure WB_LoadHTML(WebBrowser: TWebBrowser; HTMLCode: string); var sl: TStringList; ms: TMemoryStream; begin WebBrowser.Navigate('about:blank'); while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do Application.ProcessMessages; if Assigned(WebBrowser.Document) then begin sl := TStringList.Create; try ms := TMemoryStream.Create; try sl.Text := HTMLCode; sl.SaveToStream(ms); ms.Seek(0, 0); (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)); finally ms.Free; end; finally sl.Free; end; end; end;
procedure TForm1.Button1Click(Sender: TObject); var otchet: string; begin otchet:= '<html xmlns="http://www.w3.org/1999/xhtml">' + '<head> '+ '<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />'+ '<title>Документ без названия</title>' + '</head>'+ '<body>'+ '<b><font color = "red">Поле1</b><br>'+ '<img src= "1.bmp">' + '</body>'+ '</html>';
WB_LoadHTML(WebBrowser1, otchet); end;
end.
|
Картинка не отображается. Лежит картинка рядом с exe. Как отобразить? |