具體情況是:用瀏覽器保存網頁到本地之后,想通過TCppWebBrowser讀取并顯示出該網頁。
由于某種原因不能使用Navigate與Navigate2直接打開,于是用下面的方法改變TCppWebBrowser的Document。
void __fastcall TForm1::SetHtml( TCppWebBrowser *WebBrowser,AnsiString Html )
{
IStream *Stream;
HGLOBAL hHTMLText;
IPersistStreamInit *psi;
if( WebBrowser->Document == NULL ) return;
hHTMLText = GlobalAlloc( GPTR, Html.Length() + 1 );
if( 0 == hHTMLText )
{
ShowMessage( "GlobalAlloc Error" );
return;
}
CopyMemory( hHTMLText, Html.c_str(), Html.Length() );
OleCheck( CreateStreamOnHGlobal( hHTMLText, true, &Stream ) );
OleCheck(WebBrowser->Document->QueryInterface(__uuidof(IPersistStreamInit),(void **)&psi));
OleCheck(psi->InitNew());
OleCheck(psi->Load(Stream));
psi->Release();
Stream->Release();
}
這樣能顯示出htm中的內容,但是不能加載htm關聯的圖片及一些css,js檔案了。
這樣的問題該如何解決叻?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/151537.html
標籤:基礎類
下一篇:teamviewer安裝
