In my ATL project I have the window which is a host for html browser.
I have a need to create/destroy this window during runtime.
When IWebBrowser2.Navigate2
is called third time it triggers DISPID_NAVIGATEERROR
with the status INET_E_RESOURCE_NOT_FOUND (0x800C0005)
. MSDN describes it as the server or proxy was not found but I call the method for exactly the same URL as in previous sessions.
I do the following in my code:
Init routine:
ole_obj_.CoCreateInstance(CLSID_WebBrowser);
ole_obj_->SetClientSite(this);
ole_obj_->DoVerb(OLEIVERB_SHOW, NULL, site, 0, GetHWND(), &rect);
CComQIPtr<IWebBrowser2> webBrowser(ole_obj_);
DispEventAdvise(webBrowser, &DIID_DWebBrowserEvents2);
Navigate routine:
CComQIPtr<IWebBrowser2> webBrowser(ole_obj_);
webBrowser->Navigate2(&varUrl, 0, 0, 0, 0);
Destroy routine:
DispEventUnadvise(ole_obj_, &DIID_DWebBrowserEvents2);
ole_obj_->Close(OLECLOSE_NOSAVE);
ole_obj_.Release();
The interesting fact that if I comment ole_obj_->Close(OLECLOSE_NOSAVE);
it works but of course I get a memory leak.
Any advice is welcome.
User contributions licensed under CC BY-SA 3.0