How to set HTML correctly
- From: gmclee@xxxxxxxx
- Date: 21 Jun 2006 04:32:01 -0700
Hi there,
I am using the following code to change the source of HTML of
webrowser
USES_CONVERSION;
CoInitialize( NULL );
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
if ( hInst != NULL )
{
if ( hWndChild )
{
CComPtr<IHTMLDocument2> spDoc;
LRESULT lRes;
UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG,
1000, (DWORD*)&lRes );
LPFNOBJECTFROMLRESULT pfObjectFromLresult =
(LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult")
);
if ( pfObjectFromLresult != NULL )
{
HRESULT hr;
hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0,
(void**)&spDoc );
if ( SUCCEEDED(hr) )
{
CComPtr<IDispatch> spDisp;
CComQIPtr<IHTMLWindow2> spWin;
CComPtr<IHTMLElement> m_pBody;
if (spDoc)
{
hr = spDoc->get_body(&m_pBody);
if (FAILED(hr)) return;
m_pBody->put_innerHTML(HTMLCode); // HTMLCode is a BSTR
contains the HTML source
}
}
}
} // else document not ready
::FreeLibrary( hInst );
} // else Active Accessibility is not installed
CoUninitialize();
So far, everything is all right except for the HTML code contains
"<style>...</style>", for example,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>DS</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=windows-1252">
<style type="text/css">
BODY { FONT-SIZE: 11px; COLOR: RED; FONT-FAMILY: Verdana, sans-serif
}
</style>
</head>
<body>
Hello
</body>
</html>
The <style> part of the above source will be removed when I put this
source to the webbrowser with put_innerHTML. I am wondering how can I
assign the full HTML code to the browser?
Thanks.
.
- Follow-Ups:
- Re: How to set HTML correctly
- From: liangrf
- Re: How to set HTML correctly
- Prev by Date: Re: OuterHtml problem
- Next by Date: Re: OuterHtml problem
- Previous by thread: OuterHtml problem
- Next by thread: Re: How to set HTML correctly
- Index(es):