Yxd:
首先打开的document的url可以是about:blank,然后取document,就随便你咋写了,里面我给出的示例代码,你再查查MSDN就可以了。
[阅读: 851] 2005-03-17 04:00:13
void Test( long x, long y )
{
//IHTMLDocument2
IWebBrowser2 *pWebBrowser = NULL;
if ( FAILED(QueryControl( &pWebBrowser )) ) return;
if ( NULL == pWebBrowser ) return;
IHTMLDocument2 *pHTMLDocument = NULL;
pWebBrowser->get_Document( ( IDispatch** )( &pHTMLDocument ) );
if ( NULL != pHTMLDocument )
{
CString cstrMsg;
cstrMsg.Format( _T("<html><body><p style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12pt;font-weight:bold;color:#FF0000\"><a href=\"http://www.personsoft.com\">(JSMenu Previewer)</a> left mouse button down: ( %d, %d )</p></body></html>"), x, y );
SAFEARRAY *wr = SafeArrayCreateVector( VT_VARIANT, 0, 1 );
VARIANT *param = NULL;
SafeArrayAccessData( wr,( LPVOID* )( ¶m ) );
param->vt = VT_BSTR;
param->bstrVal = CComBSTR( LPCTSTR(cstrMsg) );
SafeArrayUnaccessData( wr );
pHTMLDocument->write( wr );
pHTMLDocument->close();
}
pWebBrowser->Release();
}