Proper signature for VSTO's Button.GetImage

282 Views Asked by At

I have created a working add-in for Outlook and now I try to add an image to a button. I've seen in many questions that you need to set the getImage="GetImage" property and provide a callback function for it, so I did:

public Bitmap GetImage(IRibbonControl ribbon)

However, with this method the add-in doesn't even load. I tried a couple of other signatures like

public stdole.IPictureDisp GetImage(Microsoft.Office.Core.IRibbonControl ribbon)
public Bitmap GetImage(Microsoft.Office.Core.IRibbonControl control)
public stdole.IPictureDisp GetImage(string idMso, int Width, int Height)

but none of them worked. What is the correct signature of this function?

2

There are 2 best solutions below

0
t3chb0t On BEST ANSWER

I got it and I post a self-answer, maybe it helps someone someday...

In order to use the getImage callback you must not set the image property. It's either or.

1
Eugene Astafiev On

The getImage callback's signature is listed below:

C#: IPictureDisp GetImage(IRibbonControl control)
-
VBA: Sub GetImage(control As IRibbonControl, ByRef image)
-
C++: HRESULT GetImage([in] IRibbonControl *pControl, [out, retval] IPictureDisp ** ppdispImage)
-
Visual Basic: Function GetImage(control as IRibbonControl) as IPictureDisp

Read more about the Fluent UI (aka Ribbon UI) in the following series of articles: