如何刷新整个功能区(而不仅仅是控件)?

huangapple go评论62阅读模式
英文:

How to refresh whole ribbon (not just control)?

问题

我有一个 VSTO Office/Outlook 插件和功能区,我想在某个时候重新加载它。不幸的是,ribbon.invalidate 不适用于我的情况,因为它只会重新触发 getLabel 等方法,而我需要重新构建整个功能区/分组。

我需要强制执行 GetCustomUI() 方法。

您知道如何做吗?

英文:

I have an VSTO Office/Outlook add-in and ribbon that I want to reload at some point. Unfortunatelly ribbon.invalidate is not something that suits my case, because it just re-fires getLabel etc. methods, while I need to rebuild whole ribbon/group.

I need to force executing method GetCustomUI().

Do you know how can I do it?

答案1

得分: 3

没有办法强制Office应用程序调用GetCustomUI回调函数。如果您需要在启动时默认隐藏自定义功能区UI,您可以使用功能区控件的getVisible回调,包括选项卡,以及在需要时可以调用IRibbonUI.Invalidate来调用您的控件回调,这样您可以返回适当的值并在功能区上显示您的控件。

例如,如果插件作者为按钮实现了getVisible回调过程,该函数在加载状态后被调用一次,然后如果需要更新状态,将使用缓存的状态而不是重新调用该过程。该过程保持不变,直到插件使用Invalidate方法发信号表明缓存值无效为止,此时再次调用回调过程并缓存返回响应。然后,插件可以通过调用Refresh方法强制立即更新UI

英文:

There is no way to force Office applications invoke the GetCustomUI callback. If you need to keep your custom ribbon UI hidden at startup by default you can use the getVisible callback for the ribbon controls, including tabs, and when required you may call the IRibbonUI.Invalidate to get your controls callback invoked, so you could return an appropriate value and get your controls appeared on the ribbon.

For example, if an add-in writer implements the getVisible callback procedure for a button, the function is called once, the state loads, and then if the state needs to be updated, the cached state is used instead of recalling the procedure. This process remains in place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached. The add-in can then force an immediate update of the UI by calling the Refresh method.

答案2

得分: 0

无法这样做 - 按设计,Ribbon 是静态的,即使一些控件最初可以隐藏,当它们的 getVisible 回调被调用时后来也可以显示。

请注意,控件内容可以动态填充(听起来这才是您实际想要的),这适用于 dropDown 控件。在这种情况下,您需要指定 getItemCount/getItemLabel/getItemImage/getSelectedItemIndex 回调。

请参阅 MSDN 上的 dropDown 控件描述:https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/700e4451-8706-40c5-8d7b--896e4ae21b69

英文:

No way to do that - by design, Ribbon is static, even though some controls can be hidden initially and be shown later when their getVisible callback is invoked.

Note that control contents can be populated dynamically (sounds like that is what you actually want), that applies to the dropDown control. In that case, you need to specify getItemCount/getItemLabel/getItemImage/getSelectedItemIndex callbacks.

See the dropDown control description on MSDN: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/700e4451-8706-40c5-8d7b-896e4ae21b69

huangapple
  • 本文由 发表于 2023年2月8日 20:00:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385509.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定