简体   繁体   中英

Event when user clicks to close message window

Is there a way to know when a user clicks to close the message window and before the "do you want to save changes" dialog shows up? I've registered to the Inspector.Close event but it fires only after the user has decided to save/discard the changes: ((InspectorEvents_10_Event)Inspector).Close += OnInspectorClose;

OK, so apparently I need to use the event from the mail item, not the inspector. I need to register the handler inside eg. the NewInspector handler:

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

And then prepare the handler:

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

And this OnItemClose will execute before the Inspector's Close event fires ( ((InspectorEvents_10_Event)Inspector).Close ).

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