你究竟如何覆盖InspectorEvents_CloseEventHandler以丢弃保存? [英] How exactly do you override the InspectorEvents_CloseEventHandler to discard save?

查看:84
本文介绍了你究竟如何覆盖InspectorEvents_CloseEventHandler以丢弃保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试以编程方式将Outlook MailItem显示为只读。



到目前为止,我已经能够通过NewInspector事件截取检查器窗口并进行修改以显示MailItem的修改内容,当关闭MailItem / Inspector窗口时,由于我做了修改,它总是提示保存...



我尝试过使用我所阅读和想到的所有方法,但仍然无法覆盖关闭/写入事件以丢弃更改。





((InspectorEvents_Event)检查员)。仅在检查员窗口关闭后才发生关闭事件

((ItemEvents_Event)项目)。关闭也仅在检查员关闭事件之后发生。
((ItemEvents_Event)项目。)只有在提示符点击SAVE时才会发生。


我也试过在这些事件中关闭item.Close(OlInspectorClose.olDiscard),但它并没有真正发生,因为它们都发生了s提示之后...



如何拦截关闭事件以便丢弃更改????¥b $ b

我在网上到处都读过2打线程!



解决方案

您好,



关闭
事件的Outlook项目和Inspector对象允许通过将Cancel参数设置为true来取消默认操作。 T
关闭操作是没有完成,检查员保持开放状态。因此,在检查员关闭之前会触发事件*。


到目前为止,我已经能够通过NewInspector事件截取检查器窗口并进行修改以显示修改后的内容$ b $在MailItem的b中,当关闭MailItem / Inspector窗口时,由于我做了修改,它总是提示保存...


这是因为之后没有使用Save方法。如果您不想获得任何对话框,则需要立即调用Save方法并释放所有基础COM对象。  使用  System.Runtime.InteropServices.Marshal.ReleaseComObject  到
完成使用后释放Outlook对象。然后s
et a variable to  没什么   ;
Visual Basic(
null  在
C#中)释放对象的引用。在  系统释放对象 文章。


您可能会发现以下链接很有用:


如何:为检查员实施包装并跟踪每个检查器中的项目级事件


为Outlook 2010开发Inspector Wrapper


I'm trying to programmatically display an Outlook MailItem as Read Only.

So far I've able to intercept the inspector window via NewInspector event and made my modification to display the modified content of the MailItem, when it comes to closing the MailItem/Inspector window, due to the modification I did, it always prompt for Save...

I've tried using all the ways I've read and think of, and still couldn't either override the Close/Write event to discard the changes.


((InspectorEvents_Event) inspector).Close event only happens AFTER the inspector window is closed
((ItemEvents_Event)item).Close also only happens AFTER the inspector close event
((ItemEvents_Event)item).Write only happens if you hit SAVE at the prompt

I've also tried to item.Close(OlInspectorClose.olDiscard) inside those events but it doesn't really happen because they all happens AFTER the prompt...

How the heck do can you intercept the close event in order to discard the changes????

I've read 2 dozen threads everywhere on the web!


解决方案

Hello,

The Close event of the Outlook item and Inspector objects allows to cancel the default action by setting the Cancel parameter to true. The close operation is not completed and the inspector is left open. So, the events are fired *before* the inspector is closed.

So far I've able to intercept the inspector window via NewInspector event and made my modification to display the modified content of the MailItem, when it comes to closing the MailItem/Inspector window, due to the modification I did, it always prompt for Save...

That is because the Save method wasn't used after. If you don't want to get any dialogs you need to call the Save method and release all underlying  COM objects instantly. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. Read more about that in the Systematically Releasing Objects article.

You may find the following links helpful:

How to: Implement a Wrapper for Inspectors and Track Item-Level Events in Each Inspector

Developing an Inspector Wrapper for Outlook 2010


这篇关于你究竟如何覆盖InspectorEvents_CloseEventHandler以丢弃保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆