Loading HTML content from a Stream(4) The IWebBrowser2::get_Document property on the WebBrowser control retrieves the document object that represents the DHTML Object Model for the top frame. MSHTML implements the IPersistStreamInit interface to provide the ability to load and save HTML using a stream, through the document object. The IDispatch interface for the document object can be queried for the IPersistStreamInit interface pointer using QueryInterface with an identifier of IID_IPersistStreamInit, as shown in the following code example.
Hide Example
HRESULT LoadWebBrowserFromStream(IWebBrowser* pWebBrowser, IStream* pStream){HRESULT hr;IDispatch* pHtmlDoc = NULL;IPersistStreamInit* pPersistStreamInit = NULL; // Retrieve the document object. hr = pWebBrowser->get_Document( &pHtmlDoc ); if ( SUCCEEDED(hr) ) {// Query for IPersistStreamInit.hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,(void**)&pPersistStreamInit );if ( SUCCEEDED(hr) ){// Initialize the document.hr = pPersistStreamInit->InitNew();if ( SUCCEEDED(hr) ){ // Load the contents of the stream. hr = pPersistStreamInit->Load( pStream );}pPersistStreamInit->Release();} }}
Using the IPersistStreamInit Interface to Load HTML Content