简体   繁体   中英

How to show/hide a outlook ribbon (VSTO) base on open mail?

Currently, i create a custom VSTO outlook add-on and make it works on our generated emails. However, this custom ribbon always show even if user open other mails. So my question is: is that possible to show/hide ribbon tab if and only if the open mail meets some condition; such as the subject contains a specify word.

Thx in advance.

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM