【问题标题】:Event when user clicks to close message window用户点击关闭消息窗口时的事件
【发布时间】:2017-07-26 15:55:11
【问题描述】:

有没有办法知道用户何时点击关闭消息窗口并且“您要保存更改”对话框出现之前?我已注册到 Inspector.Close 事件,但它仅在用户决定保存/放弃更改之后触发: ((InspectorEvents_10_Event)Inspector).Close += OnInspectorClose;

【问题讨论】:

  • 我已经看到了,但看不到它如何解决我的问题。
  • 只是一个想法:似乎保存消息会阻止对话框显示(它仅在邮件项存在未保存的更改时显示)。然后,您可以在关闭事件触发后将其删除。
  • 嗯,出于安全原因,我无法保存邮件,但我想我不能用 Outlook 做更多事情(我想没有“CloseStarted”事件?)。不过感谢您的提示!
  • 我想看看是否有类似 QueryClose 事件(这是一个 PowerPoint 演示文稿事件,它基本上在实际演示文稿之前触发 。关闭事件...)但看起来好像没有。

标签: c# outlook vsto outlook-addin


【解决方案1】:

好的,显然我需要使用邮件中的事件,而不是检查员。我需要在其中注册处理程序,例如。 NewInspector 处理程序:

if (inspector.CurrentItem is MailItem)
{
  MailItem item = inspector.CurrentItem as MailItem;
  ((ItemEvents_10_Event)item).Close += OnItemClose;
}

然后准备处理程序:

private void OnItemClose(ref bool cancel) //ItemEvents_10_CloseEventHandler
{
  ((ItemEvents_10_Event)_lastOpenedItem).Close -= OnItemClose;
  _lastOpenedItem.Close(OlInspectorClose.olDiscard);
}

并且这个 OnItemClose 将在 Inspector 的 Close 事件触发之前执行 (((InspectorEvents_10_Event)Inspector).Close)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-19
    • 2012-11-05
    • 1970-01-01
    • 2012-06-30
    • 2010-10-16
    • 2022-08-19
    • 1970-01-01
    • 2023-02-24
    相关资源
    最近更新 更多