简体   繁体   English

处理消息窗口关闭事件

[英]Handle message window close event

I keep seeing different variation of the code which is supposed to register an Inspector window close event but I have no idea where to put the code. 我一直看到应该注册Inspector窗口关闭事件的代码的不同变化,但是我不知道将代码放在何处。 Should it be in the addin startup function (ThisAddIn_Startup), in the item click event handler or somewhere else? 它应该在插件启动功能(ThisAddIn_Startup)中,在单击事件处理程序中还是在其他地方? And how to properly unregister the handler if it's eg. 以及如何正确注销处理程序(例如)。 registered for each mail item? 为每个邮件注册?

Here's some sample code I found (that I'm not sure where to put): 这是我发现的一些示例代码(我不确定放在哪里):

InspectorEvents_10_Event inspectorEvent = selectedItem[1].GetInspector();
inspectorEvent.Close += ItemClosed;

This tutorial also says there are two types of the Close even that I might need to handle https://sites.google.com/site/xushengxiaotech/Home/http---sites-google-com-site-xushengxiaoshome-home-handling-the-close-event-correctly-using-outlook-object-model 本教程还说,即使我可能需要处理两种https://sites.google.com/site/xushengxiaotech/Home/http---sites-google-com-site-xushengxiaoshome-home-处理最紧密事件正确-使用-前景对象模型

Where do I register the handlers for those? 我该在哪里注册处理程序?

You need to track Inspectors.NewInspector event (set up the event handler on startup). 您需要跟踪Inspectors.NewInspector事件(在启动时设置事件处理程序)。 Then when NewInspector fires, set the event handler for the Inspector.Close event on the new inspector. 然后,当NewInspector触发时,在新的检查器上为Inspector.Close事件设置事件处理程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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