Re: Callback Interface functions NOT being Called



On Jun 10, 2:27 pm, "SvenC" <Sv...@xxxxxxxxxxxxx> wrote:
Hi Devansh,

Hello All,
I have a office outlook ATL-COM addin.
In the main class I am implementing
IRibbonExtensibility and
a callback interface interface ICallbackInterface which implements the
callback functions of the buttons I create in Ribbon interface.
My interface MAP looks like this

The ribbon callbacks use IDispatch, always, so you must return
the "correct IDispatch" implementation

BEGIN_COM_MAP(CConnect)
COM_INTERFACE_ENTRY2(IDispatch, IRibbonExtensibility)

You need COM_INTERFACE_ENTRY2(IDispatch, ICallbackInterface)

BUT: you are violating COM rules by having two distinct implementations
of the same interface in one object, IDispatch in your case. You should
create a new coclass which implements ICallbackInterface so that a unique
IDispatch implementation exists for that object. Store that instance as
member in your CConnect class and hand it as callback interface to the
ribbon. That extra object might need a simple C++ callback mechanism to
communicate back to your CConnect instance.

--
SvenC

Hello SvenC,
I modified my code. Now my interface map looks like this,

BEGIN_COM_MAP(CConnect)
COM_INTERFACE_ENTRY2(IDispatch, ICallbackInterface)
COM_INTERFACE_ENTRY(AddInDesignerObjects::IDTExtensibility2)
COM_INTERFACE_ENTRY(IRibbonExtensibility)
COM_INTERFACE_ENTRY(ICallbackInterface)
COM_INTERFACE_ENTRY_IID(IID_IExchExt, IExchExt)
COM_INTERFACE_ENTRY_IID(IID_IExchExtSessionEvents,
IExchExtSessionEvents)
COM_INTERFACE_ENTRY_IID(IID_IExchExtMessageEvents,
IExchExtMessageEvents)
END_COM_MAP()

My callback function "ButtonClicked" is still NOT being called.
Outlook is not able to find it.

As you said, that in this implementation I am violating COM rules by
having two distinct implementations of the same interface in one
object i.e. IDispatch,
so my question here is, where am I implementing it twice. I could see
only one implementation, the one which is associated with
ICallbackInterface in
COM_INTERFACE_ENTRY2(IDispatch, ICallbackInterface)

In fact similar kind of application was working for me but in this new
application I am not able to make the callback function work, I do not
know why..

Kindly help me.

Thanks,
Devansh
.