MS Word自定义任务窗格在单击“文件”菜单时消失。

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

MS Word Custom Task Pane disappears when clicking on File menu

问题

I created an addin for MS Word 365 using Custom Task Pane. Through the OnVisibleChanged method I am able to determine when to open/close the addin. The problem: by clicking the File menu (top right on the ribbon), its visibility change to false and the component disappears as if you had clicked on the "X" button. Is there any way to distinguish the close done by the "X" button? Or is there a way to not close the addin when clicking on File?

英文:

I created an addin for MS Word 365 using Custom Task Pane. Through the OnVisibleChanged method I am able to determine when to open/close the addin. The problem: by clicking the File menu (top right on the ribbon), its visibility change to false and the component disappears as if you had clicked on the "X" button. Is there any way to distinguish the close done by the "X" button? Or is there a way to not close the addin when clicking on File?

答案1

得分: 1

自定义任务窗格不提供任何关于此的事件。这是因为它并没有真正关闭,当它显示时,后台UI会隐藏任何UI。

您可以通过处理Office应用程序中的File菜单打开时的Backstage UIonHideonShow事件来检测,这样您就会在后台UI关闭和打开时得到通知。

onShow回调应该具有以下签名:

C#: void OnShow(object contextObject)
Visual Basic: Sub OnShow(contextObject As Object)
C++: HRESULT OnShow([in] Object *pContextObject)

onHide回调应该具有以下签名:

C#: void OnHide(object contextObject)
Visual Basic: Sub OnHide(contextObject As Object)
C++: HRESULT OnHide([in] Object *pContextObject)
英文:

The custom task pane doesn't provide any event for that. That is because it is not really closed, the backstage UI hides any UI behind when it is displayed.

You can detect when the File menu is opened in Office applications by handling the Backstage UI's onHide and onShow events, so that you will be aware when the backstage UI is closed and opened respectively.

The onShow callback should have the following signature:

VBA: Sub OnShow(contextObject As Object)

C#: void OnShow(object contextObject)

Visual Basic: Sub OnShow(contextObject As Object)

C++: HRESULT OnShow([in] Object *pContextObject)

The onHide callback should have the following signature:

VBA: Sub OnHide(contextObject As Object)

C#: void OnHide(object contextObject)

Visual Basic: Sub OnHide(contextObject As Object)

C++: HRESULT OnHide([in] Object *pContextObject)

huangapple
  • 本文由 发表于 2023年5月15日 00:01:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248424.html
匿名

发表评论

匿名网友

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

确定