如何利用TWebBrowser來顯示動態的內容
發表於 : 2008年 11月 28日, 12:34
使用 delphi 中的 TWebBrowser 來瀏覽網頁或是檔案是很方便的一種操作方式, 但如何能不瀏覽檔案, 而直接對 TWebBrowser 寫入呢? 當然是可以先利用一個暫存檔來處理, 但是使用起來仍然不是很方便, 下面是利用 TWebBrowser 的 Document 的 IHTMLDocument2 介面中的 Write 方法來處理這個狀況, 請參考,
1. 首先先放一個 TWebBrowser 放到 form 上
2. 記得要 use MSHtml 及 ActiveX
3. 再寫下下面的程式即可,
參考資料: http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=51494
相關文章,
http://www.delphidabbler.com/articles.php?article=14
1. 首先先放一個 TWebBrowser 放到 form 上
2. 記得要 use MSHtml 及 ActiveX
3. 再寫下下面的程式即可,
代碼: 選擇全部
procedure Tform1.Button2Click(Sender: TObject);
var
v: Variant;
hd: IHTMLDocument2;
s: string;
begin
hd := WebBrowser1.Document as IHTMLDocument2;
if hd = nil then
begin
WebBrowser1.Navigate('aboutblank');
hd := WebBrowser1.Document as IHTMLDocument2;
end;
v := VarArrayCreate([0,0],varVariant);
s := '<HTML><BODY>MY TEST</BODY></HTML>';
v[0] := s;
hd.write(pSafearray(TVarData(v).VArray));
hd.close;
end;
參考資料: http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=51494
相關文章,
http://www.delphidabbler.com/articles.php?article=14