Re: Help killing popus with OnNewWindow2 event

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 06/28/04


Date: Mon, 28 Jun 2004 09:59:06 -0400


"Al" <morotin2@hotmail.com> wrote in message
news:86dfae6f.0406271744.15c6ee24@posting.google.com
> Right now I'm trying to capture the OnNewWindow2 event and create a
> new instance of a Webbrowser control object. I then assign the
> IDispatch value to the ppdisp value of the event:
>
> CWebBrowser2 * m_pIE;
> HRESULT hr;
> hr = CoCreateInstance(CLSID_InternetExplorer,
> NULL,
> CLSCTX_LOCAL_SERVER,
> IID_IWebBrowser2,
> (void**)&m_pIE);

You have a bug here. You need to pass IWebBrowser2** to
CoCreateInstance, not CWebBrowser2** (I assume the latter is MFC class
wizard-generated wrapper). You effectively cast from IWebBrowser2* to
CWebBrowser2* - you can't do that, the two are not interchangeable.

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken