1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
procedure WBLoadHTML(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 TFPrincipale.Button1Click(Sender: TObject);
var
Page : string;
begin
Page := '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
'<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Google Maps JavaScript API Example</title>' +
'<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAsT1ziiaxKxMrk3lpf5RRFxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRR9-V34RKMA8vvIjZk2Wty69Akiw" type="text/javascript"></script>' +
'<script type="text/javascript">//<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); } } //]]> </script>' +
'</head><body onload="load()" onunload="GUnload()"><div id="map" style="width: 500px; height: 300px"></div></body></html>';
WBLoadHTML(WebBrowser1,Page);
end; |
Partager