BCB下如何改变CppWebBrowser的Html内容

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 funtek 的 blog

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;
}

本文关键:BCB CppWebBrowser IE内核
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top