Yes, it is possible. Define ribbon callbacks, especially you will be interested in the getVisible
one, and use the IRibbonUI.Invalidate or IRibbonUI.InvalidateControl when you need to hide or show your ribbon controls. The getVisible
callback has the following signature:
C#: bool GetVisible(IRibbonControl control)
VBA: Sub GetVisible(control As IRibbonControl, ByRef visible)
C++: HRESULT GetVisible([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfVisible)
Visual Basic: Function GetVisible(control As IRibbonControl) As Boolean
For example, if an add-in writer implements the getImage
callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in place for the control until the add-in signals that the cached values are invalid by using the InvalidateControl
method, at which time, the callback procedure is again called and the return response is cached.
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles: