Found this at microsoft;
The IPersistStreamInit interface, and its associated methods, can be used to load HTML content from a stream using the WebBrowser control...
Exactly what I would like to do
They provide this code, which i am struggling to convert to PB.
Code: Select all
void myObject::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
HRESULT hr;
IUnknown* pUnkBrowser = NULL;
IUnknown* pUnkDisp = NULL;
IStream* pStream = NULL;
HGLOBAL hHTMLText;
static TCHAR szHTMLText[] = "<html><h1>Stream Test</h1><p>This HTML content is/
being loaded from a stream.</html>";
// Is this the DocumentComplete event for the top frame window?
// Check COM identity: compare IUnknown interface pointers.
hr = m_pBrowser->QueryInterface( IID_IUnknown, (void**)&pUnkBrowser );
if ( SUCCEEDED(hr) )
{
hr = pDisp->QueryInterface( IID_IUnknown, (void**)&pUnkDisp );
if ( SUCCEEDED(hr) )
{
if ( pUnkBrowser == pUnkDisp )
{ // This is the DocumentComplete event for the top
// frame - page is loaded!
// Create a stream containing the HTML.
// Alternatively, this stream may have been passed to us.
size_t = cchLength;
// TODO: Safely determine the length of szHTMLText in TCHAR.
hHTMLText = GlobalAlloc( GPTR, cchLength+1 );
if ( hHTMLText )
{
size_t cchMax = 256;
StringCchCopy((TCHAR*)hHTMLText, cchMax + 1, szHTMLText);
// TODO: Add error handling code here.
hr = CreateStreamOnHGlobal( hHTMLText, TRUE, &pStream );
if ( SUCCEEDED(hr) )
{
// Call the helper function to load the browser from the stream.
LoadWebBrowserFromStream( m_pBrowser, pStream );
pStream->Release();
}
GlobalFree( hHTMLText );
}
}
pUnkDisp->Release();
}
pUnkBrowser->Release();
}
}
; and this next bit too
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();
}
}
}
I would want to use a WebGadget then load the HTML into it using this IPersistStreamInit interface.
Can anybody help get this working in PB?
Thanks
