(Gast)
n/a Beiträge
|
Re: LoadHTMLToWebBrowser(Webbrowser1,'01.htm');
13. Sep 2007, 18:13
Zitat von Die Muhkuh:
Glaub nur nicht, dass ich deinen ganzen Code jetzt durchschaue
Ich wollte die relevanten Codestellen und nicht mehr oder weniger
Delphi-Quellcode:
implementation
{$R *.dfm}
procedure Document_SetHTML(Document: IDispatch; const HTMLCode: string);
var
ms: TStringStream;
begin
if Assigned(Document) then
begin
ms := TStringStream.Create(HTMLCode);
try
ms.Seek(0, 0);
OleCheck((Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)));
finally
ms.Free;
end;
end;
end;
function Document_GetHTML(Document: IDispatch):string;
var
ms: TStringStream;
begin
Result := '';
if Assigned(Document) then
begin
ms := TStringStream.Create(Result);
try
OleCheck((Document as IPersistStreamInit).Save(TStreamAdapter.Create(ms),False));
Result := ms.DataString;
finally
ms.Free;
end;
end;
end;
procedure WB_SetHTML(WebBrowser: TWebBrowser; const HTMLCode: string);
begin
if not Assigned(WebBrowser.Document) then
WebBrowser.Navigate('about:blank');
WaitForBrowser(WebBrowser);
Document_SetHTML(WebBrowser.Document, HTMLCode);
end;
function WB_GetHTML(WebBrowser: TWebBrowser): string;
begin
Result := Document_GetHTML(WebBrowser.Document);
end;
procedure TfrmMain.Button1Click(Sender: TObject);
var Dateiinhalt: TStringList;
begin
Dateiinhalt := TStringList.Create;
try
Dateiinhalt.LoadFromFile(ListBox1.Items[0]);
WB_SetHTML(WebBrowser1, Dateiinhalt.text);
finally
FreeAndNil(Dateiinhalt);
end;
end;
|
|
Zitat
|