Im working on a Browser Helper Object, and I am trying to access the IWebBrowser2 that fires an event. With NavigateComplete2 and other events I can easly do it because I get the pointer on the parameters of Invoke.
But I was reading this on msdn and it says the only parameter for TitleChange event is the title, so how do I get the pointer to the webbrowser interface from the event TitleChange?
Here's how I am getting it with other events:
HRESULT STDMETHODCALLTYPE CSiteEvents::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS __RPC_FAR *Params, VARIANT __RPC_FAR *pVarResult,
EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr )
{
switch ( dispIdMember )
{
case DISPID_DOCUMENTCOMPLETE:
{
IWebBrowser2 *pBrowser = GetBrowser(Params->rgvarg[1]);
// stuff
pBrowser->Release();
}
break;
}
}
IWebBrowser2* GetBrowser(const VARIANT &_Argument)
{
IWebBrowser2 *pBrowser = NULL;
if (_Argument.vt == VT_DISPATCH)
{
HRESULT hr;
IDispatch *pDisp = _Argument.pdispVal;
if (pDisp)
{
hr = pDisp->QueryInterface( IID_IWebBrowser2, reinterpret_cast<void **>(&pBrowser) );
if ( FAILED(hr) )
pBrowser = NULL;
}
}
return pBrowser;
}
I am using Visual Studio 2010.