Problem hosting WebBrowser control in an ATL app.

Posted by Andrew Bucknell on Stack Overflow See other posts from Stack Overflow or by Andrew Bucknell
Published on 2010-03-20T00:16:03Z Indexed on 2010/03/20 0:21 UTC
Read the original article Hit count: 835

I have a legacy atl app that hosts a webbrowser control in an ATL window. I create an instance of the client to host the browser using the following sequence

CComPtr<IOleObject> spOleObject;
HRESULT hr = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, ID_IOleObject,(void**)&spOleObject);

spOleObject->SetClientSite(this);
GetClientRect(&rcClient);
hr = spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, m_hWnd, &rcClient);

hr = AtlAdvise(m_spWebBrowser, GetUnknown(), DIID_DWebBrowserEvents2, &m_dwCookie);

CComVariant navvar(navurl);
m_spWebBrowser->Navigate2(&navvar, NULL, NULL, NULL, NULL);

This sequence works fine to create the initial browse window. The call to navigate2 works and if I look at the window via spy++ I have Shell Embedding -> Shell DocObject View -> Internet Explorer_Server. When a popup occurs (detected through NewWindow3) I launch a new window and execute the same code sequence for the new window. In the popup window the navigate2 doesnt work, and when I look at this new window in spy++ I just have Shell Embedding. I get the same problem even if I instantiate the popup window on startup, so its not related to NewWindow3 at all - it seems the second instance of the web control isnt instantiating even though all the calls return S_OK.

This sequence worked fine under IE7 but now I am using IE8 and the popup window isnt working. There is clearly something I am missing but I cant guess what it may be. Any suggestions would be incredibly helpful.

© Stack Overflow or respective owner

Related posts about internet

Related posts about internet-explorer-7