Re: Handling DISPID_AMBIENT_DLCONTROL in IDispatch::Invoke
"herc" <cartoper@gmail.com> wrote in message
news:1180241654.179635.315300@q75g2000hsh.googlegroups.com
I am working on an ATL8 program that uses the WebBrowser control. I
need to implement the DISPID_AMBIENT_DLCONTROL ambient property but am
stumped at how to actually implement the IDispatch::Invoke(). I am
using the IAxWinAmbientDispatchEx interface from the CAxWindow control
and giving it my own custom implementation of IDispatch:
class CAmbientDispatch :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatch
{
public:
CAmbientDispatch() {}
BEGIN_COM_MAP(CAmbientDispatch)
COM_INTERFACE_ENTRY(IUnknown)
COM_INTERFACE_ENTRY(IDispatch)
You don't need an explicit IUnknown entry. IDispatch one is sufficient.
It's harmless though.
STDMETHOD(Invoke)(
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS *pDispParams,
VARIANT *pVarResult,
EXCEPINFO *pExcepInfo,
UINT *puArgErr)
{
// Change user agent for this web browser host during
hyperlinks
if (dispIdMember == DISPID_AMBIENT_USERAGENT)
{
return S_OK;
}
return DISP_E_MEMBERNOTFOUND;
}
};
I am trying to set the user-agent, the question is, how exactly do I
do that? The pVarResult is NULL
Are you sure pVarResult is NULL? That would be most unusual. I find it
hard to believe, no offense intended. pVarResult is not supposed to be
NULL, and you are supposed to pack your return value into it. Are you
sure you are not looking at the contents of pVarResult variant, but at
pVarResult pointer itself?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925