如何改变CppWebBrowser的Html内容
1个回答
推荐于2016-02-06
展开全部
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 ) );
try
{
OleCheck( WebBrowser->Document->QueryInterface( __uuidof(IPersistStreamInit), (void **)&psi ) );
try
{
OleCheck( psi->InitNew() );
OleCheck( psi->Load(Stream) );
}
catch( ... )
{
delete psi;
}
}
catch( ... )
{
delete Stream;
}
delete psi;
delete Stream;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询