Re: How to replace the html contents using put_outerHTML?
- From: liangrf@xxxxxxxxx
- Date: 1 Mar 2007 21:37:43 -0800
On Feb 28, 3:22 am, john Lee <john9...@xxxxxxxxx> wrote:
Dear.
I want to replace the html contents in IE using COM module functions,
However,
The following functions doesn't work well.
Please check the following functions for replacing the html contents as
effect.
Best regards.
int CCommonInfo::PutStringTOIW(IWebBrowser2 *mWeb, CString strReplace)
{
IHTMLDocument2 *Document;
IDispatch *Dispatch;
HRESULT Result;
CString strHtml;
IHTMLElement *m_pBody;
IHTMLElement *lpParentElm;
IStream* pStream = NULL;
// HGLOBAL hHTMLText;
Result = mWeb->get_Document(&Dispatch);
if (FAILED(Result) || Dispatch == NULL)
return -1;
Result = Dispatch->QueryInterface(IID_IHTMLDocument2, (void **) &Document);
Dispatch->Release();
if (FAILED(Result))
return -1;
if (Document)
{
// Get the BODY object
Result = Document->get_body(&m_pBody);
Document->Release();
Document = NULL;
if (FAILED(Result) || !m_pBody)
return Result;
// Get the HTML text
BSTR bstrHTMLText = strReplace.AllocSysString();
// the parent of BODY is HTML
m_pBody->get_parentElement(&lpParentElm);
lpParentElm->put_outerHTML((BSTR)bstrHTMLText);
m_pBody->Release();
lpParentElm->Release();
lpParentElm = NULL;
m_pBody = NULL;
Document = NULL;
Dispatch = NULL;
::SysFreeString (bstrHTMLText);
}
return strOrg.GetLength() ;
}
Try to query IID_IPersistStreamInit interface by ihtmldocument.
The example is as follows:
http://groups.google.com/group/microsoft.public.inetsdk.programming.webbrowser_ctl/browse_thread/thread/b0feb3fbea79088d/b9685746eba341ef?lnk=gst&q=IID_IPersistStreamInit&rnum=1&hl=en#b9685746eba341ef
.
- Prev by Date: axWebBrowser and javascript errors
- Next by Date: embedded browser control that accepts all keyboard input.
- Previous by thread: axWebBrowser and javascript errors
- Next by thread: embedded browser control that accepts all keyboard input.
- Index(es):
Relevant Pages
|