1
votes

I have a custom ribbon in Visio that displays correctly, except when I click to expand a SplitButton. When I expand the SplitButton, it calls the GetImage callback for my ribbon, and loads the bmp file using LoadPicture, but does not actually display in Visio. The next time I expand the SplitButton everything is fine.

Is there something I need to do in the callback to prompt the ribbon to display correctly when using a SplitButton?

We currently use a class that implements IRibbonExtensibility with callbacks for GetImage and OnAction, and they work fine for normal buttons, but we get this behavior only with SplitButton usage.

This is what I see the first time I click the drop down:

The Auto Pipe button is the top level and there should be two buttons in the SplitButton

2
did you tried control.invalidateArya
Yes I did, but it made no difference. RibbonUI.Invalidate makes it worse; the SplitButton button never shows up.Jon Fournier

2 Answers

0
votes

It is not clear what code is used for the custom Ribbon UI.

The getImage callback should have the following signature:

 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

Make sure that you return the IPictureDisp instance which points to the image you loaded. See Chapter 11: Creating Dynamic Ribbon Customizations (2 of 2) for a sample code.

0
votes

The issue came down to the use of the DoEvents statement, which was added to our stack trace code in our codebase. Every time we enter a routine we push the routine name onto a call stack and then pop it on exit, but this routine also had added the DoEvents statement to help break out of any loops during development.

It would seem that, since we add the ribbon via a Document Created/Opened event, executing DoEvents must be causing Visio to not correctly process the ribbon loading callbacks. Removing the DoEvents statement fixed the problem.