Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Mon, 26 Feb 2007 00:14:08 -0800,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


How to use put_outerHTML for replacing the html contents?   
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() ;
}
date: Mon, 26 Feb 2007 00:14:08 -0800   author:   john Lee

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us