News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

LoadHtmlFromStream

Started by RD, February 19, 2011, 08:02:14 AM

Previous topic - Next topic

RD

Html loaded from memory
Applications interact with the web page, I found MSDN, IHTMLDocument2, How can I load a data stream WEB as well?

void DisplayDirect(CString sHtml);
HRESULT LoadHtmlFromStream(IStream* pStream);



void CHTMLDlg::DisplayDirect(CString sHtml)
{
HRESULT hr;
HGLOBAL hHTMLText;
IStream* pStream = NULL;

hHTMLText = GlobalAlloc( GPTR, sHtml.GetLength()+1 );
if (hHTMLText) {
lstrcpy((char*)hHTMLText, sHtml);
hr = CreateStreamOnHGlobal(hHTMLText, TRUE, &pStream );
if (SUCCEEDED(hr)) {
LoadHtmlFromStream(pStream);
pStream->Release();
}
}
}

HRESULT CHMTLDlg::LoadHtmlFromStream(IStream* pStream)
{
HRESULT hr;
IDispatch* pHtmlDoc = NULL;
IPersistStreamInit* pPersistStreamInit = NULL;

internetExplorer.Navigate( _T("about:blank"), NULL, NULL, NULL, NULL );
pHtmlDoc = internetExplorer.GetDocument(); // m_WebBrowser is your control

if (pHtmlDoc)
{
pHtmlDoc->QueryInterface( IID_IPersistStreamInit, (void**)&pPersistStreamInit );
pPersistStreamInit->InitNew();
pPersistStreamInit->Load( pStream );
pPersistStreamInit->Release();
}
return hr;
}

usage

DisplayDirect("<html><body><h1>test</h1></body></html>");