分享

用webbrowser显示字符串

 aaie_ 2011-09-19
uses   ActiveX,MSHTML   //加上两个单元!
procedure   ShowInWebBrowser(WebB:TWebBrowser;Str:String);
var
v:   Variant;
HTMLDocument:   IHTMLDocument2;
begin
HTMLDocument   :=   WebB.Document   as   IHTMLDocument2;
if   (assigned(HtmlDocument))   then   begin
v   :=   VarArrayCreate([0,   0],   varVariant);
v[0]   :=   str;   //that   is   to   be   shown
HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
HTMLDocument.Close;
end;
end;
//调用
str= '输出内容 ';
ShowInWebBrowser(WebBrowser1, '输出内容 ');//可以为任意内容,包括HTML代码!
还有种方法,不如上面的灵活,但很简单实用!
str= '输出内容 ';
webbrowser1.Navigate( 'about: '+str);

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章