to 左轻侯
我看了你给的源代码,我依葫芦画瓢去做,不过我的代码运行时会出错,这方面的东西我第
一次做,还请你多多指教。content是不是就是html的源代码?
procedure ShowHtml(Browser:TWebBrowser;content: string);
var
vv: Variant;
HTMLDocument: IHTMLDocument2;
begin
vv := VarArrayCreate([0,0],varVariant);
vv[0] := content;
HTMLDocument := browser.Document as IHTMLDocument2;
HTMLDocument.write(PSafeArray(TVarData(vv).VArray));//执行到这里出错
HTMLDocument.charset := 'gb2312';
HTMLDocument.close;
end;
procedure TForm1.ShowHtml1Click(Sender: TObject);
var s:string;
begin
s:='<html><head><title>Just for test</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>'+
'<body bgcolor="#FFFFFF" text="#000000"><div align="center">Color: <font color="#FF0000">Red</font> </div></body></html>';
showhtml(webbrowser1,s);
end;