Greetings...
I'm trying to load HTML from memory into the IHTMLDocument2:
(OnInitDialog)
(internetExplorer -- created by "Insert ActiveX Control" from "Microsoft Web Browser")Code:InfoStr = "<html><body><h1>test</h1></body></html>"; CComVariant address("about:blank"); internetExplorer.Navigate2(&address, NULL, NULL, NULL, NULL); LPDISPATCH documentDispatch = internetExplorer.get_Document(); if (documentDispatch) { CComPtr<IHTMLDocument2> document; if (SUCCEEDED(documentDispatch->QueryInterface(__uuidof(IHTMLDocument2), (void**)&document)) && document) { CComPtr<IPersistStreamInit> persistStreamInit; if (SUCCEEDED(document->QueryInterface(__uuidof(IPersistStreamInit), (void**)&persistStreamInit)) && persistStreamInit) { if (SUCCEEDED(persistStreamInit->InitNew())) { TCHAR* memory = (TCHAR*)GlobalAlloc(GMEM_MOVEABLE, (InfoStr.GetLength() + 1)*sizeof(TCHAR)); if (memory) { _tcscpy(memory, InfoStr.GetBuffer()); memory[InfoStr.GetLength()] = 0; CComPtr<IStream> stream; if (CreateStreamOnHGlobal((HGLOBAL)memory, TRUE, &stream) == S_OK) { HRESULT result = persistStreamInit->Load(stream); bool stop = true; } } } } } }
persistStreamInit->Load returns S_OK, but internetExplorer shows an empty page.
What's wrong here?
Best regards...




Reply With Quote