uses ActiveX;
procedure WebBrowserText(var WebBrowser: TWebBrowser; TextHTML: string);
var sl: TStringList;
ms: TMemoryStream;
begin
If Assigned(WebBrowser.Document) then
begin
sl:=TStringList.Create;
ms:=TMemoryStream.Create;
sl.Text:=TextHTML;
sl.SaveToStream(ms);
ms.Seek(0, 0);
(WebBrowser.Document as IPersistStreamInit).Load(tStreamAdapter.Create(ms));
FreeAndNil(ms);
FreeAndNil(sl);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var OLEHtmlText: OLEVariant;
begin
OLEHtmlText:='about:';
WebBrowser1.Navigate2(OLEHtmlText);
end;
procedure TForm1.Button1Click(Sender: TObject);
var s: string;
begin
s:=FormatDateTime('dd.mm.yyyy hh:nn:ss', Now);
s:=Format('Date / Time: <b>%s</b>', [s]);
WebBrowserText(WebBrowser1, s);
end;
Примечание. Компонент TWebBrowser находится на вкладке "Internet".
|