IRibbonExtensibility integration issue for unmanaged AddIn

G

gf

Hello,

i am trying to integrate support for Outlook 2007s Ribbon interface in an otherwise already working AddIn using C++/ATL.
After quite some reading around however i still haven't come to the Point where IRibbonExtensibility::GetCustomUI() is actually called.
The main addin class looks like this:

class ATL_NO_VTABLE CAddin :
...
public IDispatchImpl<IRibbonExtensibility, &__uuidof(IRibbonExtensibility), &LIBID_Office, 2, 4>
{
...
BEGIN_COM_MAP(CAddin)
...
COM_INTERFACE_ENTRY(IRibbonExtensibility)
END_COM_MAP()
...
STDMETHOD(GetCustomUI)(BSTR RibbonID, BSTR * RibbonXml)
{
MessageBox(NULL, "CAddin::GetCustomUI()", "", MB_OK);
return E_NOTIMPL;
};
...
};
OBJECT_ENTRY_AUTO(__uuidof(Addin), CAddin)

As already mentioned, GetCustomUI() never even gets hit - and i am rather clueless now.
Am i supposed to add additional interface entries to the addins main idl file?
If so, what exactly? My websearch and trial and error didn't give me any working results yet.
Any suggestions are appreciated.

Thanks
 
K

Ken Slovak - [MVP - Outlook]

I don't do C++ so I can't help with the exact code you need but the rule is
that whatever class is handling the interfaces for IDTExtensibilty is the
class that needs to handle the interfaces for IRibbonExtensibility. Are you
doing that?
 
S

Scott McPhillips [MVP]

This looks OK to me and I don't know why your GetCustomUI is not being
called. I did the same thing based on this sample:

http://blogs.msdn.com/jensenh/archive/2006/12/08/using-ribbonx-with-c-and-atl.aspx

and it is working just fine for me (in C++/ATL). The sample at that link
also establishes a callback interface to receive ribbon control
notifications, and that interface must be in your IDL and it must be
registered. With VS2005 I found it necessary to hand craft an .rgs file to
get the interface registered. I wouldn't think that's relevant to getting
the GetCustomUI call, but maybe if you don't register the callback interface
the ribbon ignores you(?)
 
G

gf

kenslovak wrote on Tue, 22 July 2008 14:55
I don't do C++ so I can't help with the exact code you need but the rule is
that whatever class is handling the interfaces for IDTExtensibilty is the
class that needs to handle the interfaces for IRibbonExtensibility. Are you
doing that?

Yes, IDTExtensibility2. i just skipped it to keep the sample clear.
org-dot-mvps-at-scott wrote on Tue, 22 July 2008 16:24
I did the same thing based on this sample:
http://blogs.msdn.com/jensenh/archive/2006/12/08/using-ribbo nx-with-c-and-atl.aspx

Same here.
org-dot-mvps-at-scott wrote on Tue, 22 July 2008 16:24
I wouldn't think that's relevant to getting
the GetCustomUI call, but maybe if you don't register the callback interface
the ribbon ignores you(?)

Unbelievable, you are right. Implementing the callback-interface made it work.
I thought it would be logical to assume Outlook first queries for the iribbonextensibility interface and for the callback only if needed.
Oh well, thank you :)
 
G

gf

Sadly it did work at first, but now for some reason the Callback Interface isn't accessed anymore at all.
As there are no error messages for onAction as well as loadImage methods i guess Outlook doesn't even call the callback interfaces Invoke-implementation.
After more then a day of trying different things i am again out of clues.
Only thing i can imagine is that Outlooks QueryInterface for IDispatch does not return the ICallBackInterface - but that should be taken care of by COM_INTERFACE_ENTRY2().

The Ole/COM-Object Viewer shows everything seems to be fine, wether i view the dlls typelib directly or the registered typelib.
Also the not Ribbon-Specific code and IRibbonExtensibility still work fine.

Any hints would be appreciated.

The simplified relevant source and IDL (taken from the Object Viewer):

class ATL_NO_VTABLE CAddin :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CAddin, &CLSID_Addin>,
public IDispatchImpl<IDTExtensibility2, &IID__IDTExtensibility2, &LIBID_AddInDesignerObjects, 1, 0>,
public IDispatchImpl<IRibbonExtensibility, &__uuidof(IRibbonExtensibility), &LIBID_Office , /* wMajor = */ 2, /* wMinor = */ 4>,
public IDispatchImpl<ICallbackInterface, &__uuidof(ICallbackInterface), &LIBID_OUTLOOKADDINLib, /* wMajor = */ 1, /* wMinor = */ 0>,
[... IDispEventSimpleImpl<>s ...]
{
[...]
BEGIN_COM_MAP(CAddin)
COM_INTERFACE_ENTRY2(IDispatch, ICallbackInterface)
COM_INTERFACE_ENTRY(IDTExtensibility2)
COM_INTERFACE_ENTRY(IRibbonExtensibility)
COM_INTERFACE_ENTRY(ICallbackInterface)
END_COM_MAP()
[...]
};
OBJECT_ENTRY_AUTO(__uuidof(Addin), CAddin)



[
uuid(...), version(1.0),
helpstring("Outlook Addin 1.0 library")
]
library OUTLOOKADDINLib
{
importlib("stdole2.tlb");

interface ICallbackInterface;

[
uuid(...),
helpstring("Addin Class")
]
coclass Addin {
[default] interface IUnknown;
};
[
uuid(...),
helpstring("CallbackInterface Class")
]
coclass CallbackInterface { // most probably not needed
[default] interface ICallbackInterface;
};
[
odl, uuid(...),
helpstring("ICallbackInterface Interface"),
dual, nonextensible, oleautomation
]
interface ICallbackInterface : IDispatch {
[id(0x00000001), helpstring("method ButtonClicked")]
HRESULT ButtonClicked([in] IDispatch* RibbonControl);
};

[...]
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top