I am hosting a web browser in this case IE
I have implemented IMoniker, and had to implement two functions with respect to following forum
Following Forum[
^]
Two Methods: GetDisplayName and BindToStorage
GetDisplayName to solve the page url problem and BindToStorage for web page. BindToStorage just returns the pointer to Istream Interface.
return htmlStream->lpVtbl->QueryInterface(htmlStream, &IID_IStream, ppvObj);
HRESULT STDMETHODCALLTYPE Mon_GetDisplayName(IMoniker FAR* This,IBindCtx *pbc,IMoniker *pmkToLeft,LPOLESTR pszDisplayName)
{
if (!ppszDisplayName) return E_INVALIDARG;
*ppszDisplayName = NULL;
CoGetMalloc(1,&my_malloc);
pszlen = pageurl_len;
psz = my_malloc->lpVtbl->Alloc(my_malloc, 1024*sizeof(wchar_t));
wcscpy(psz, pageurl);
}
Here, as per the documentation Allocated memory shld be freed by caller, but how can i, because i have not implemented the interface from where this method is being called, that is I have not implemented the IPersistMoniker which is calling this function when i use load method to load the html page. This may be a problem, but how do i fix it??
htmlDoc2->lpVtbl->QueryInterface(htmlDoc2, &IID_IPersistMoniker, &my_persist_moniker);
my_imoniker.lpVtbl = &MyIMonikerVtbl; CreateBindCtx(0, &my_bindctx);
hr = my_persist_moniker->lpVtbl->Load(my_persist_moniker, FALSE, &my_imoniker, my_bindctx,0);
htmlStream->lpVtbl->Release(htmlStream);
my_persist_moniker->lpVtbl->Release(my_persist_moniker);
my_bindctx->lpVtbl->Release(my_bindctx);
The above code is what i use for loading the web page from stream.
and this is how i am building the stream to be loaded
HGLOBAL htmlContents = GlobalAlloc(GHND, size*sizeof(WCHAR));
HGLOBAL ptr = GlobalLock(htmlContents) ((wchar_t*) ptr)[0] = 0xfeff; wcscpy((wchar_t*) (ptr)+1, wpage);
GlobalUnLock(htmlContents);
CreateStreamOnHGlobal(htmlContents, TRUE, &htmlStream);
Thats it, now my first page load absolutely ok, but when i try to navigate to the page, which I am handling in BeforeNavigate2 as told earlier, application crashes..