[英]How to detect the close event of MMC 3.0 SnapIn written in C#
Folks, I am creating a MMC3.0 SnapIn program with C#. 伙计们,我正在用C#创建一个MMC3.0 SnapIn程序。 There I have some scope nodes and I have FormViewDescription's where I used C# UserControl instances to display some data.
那里有一些作用域节点,还有FormViewDescription的地方,在这里我使用C#UserControl实例显示一些数据。 And my intent is, user must see and update those data into the UserControl and there is a Save button onto that UserControl which user should press at the end of their editing and I will persist that change then.
我的意图是,用户必须查看并更新这些数据到UserControl中,并且在该UserControl上有一个Save按钮,在编辑结束时用户应按该按钮,然后我将坚持所做的更改。
Now the problem is, If after making some changes, user closes the SnapIn window, all his changes are gone :( I need to prevent user before closing this window with a dialog that "Save before quiting " (or something like that - you know the standard feature of any editor program). But could not found a way to do so. Any suggestions for me? 现在的问题是,如果在进行了一些更改之后,用户关闭了SnapIn窗口,则他的所有更改均已消失:(我需要在关闭该窗口之前使用“退出前保存”对话框(或类似的对话框-这样,您需要阻止用户任何编辑器程序的标准功能),但找不到方法。对我有什么建议吗?
Would be appreciated much! 将不胜感激!
Coincidentally, I have also just created an MMC in much the same manner as you described above but after much searching (and frustration) I could not find any way to cancel the close event. 巧合的是,我也以与上述相同的方式创建了MMC,但经过大量搜索(和沮丧)之后,我找不到取消取消事件的任何方法。 I recommend changing your approach as explained below.
我建议按照以下说明更改您的方法。
First of all have a look at how most of the MMC's that are already in Windows handle changing settings. 首先,了解一下Windows中已经存在的大多数MMC如何处理更改设置。 Usually if you want to change a setting you select an item in a ListView and right-click 'Properties' to bring up a settings form and make your changes there.
通常,如果要更改设置,请在ListView中选择一个项目,然后右键单击“属性”以调出设置表单并在此处进行更改。
Bringing up a form gives the developer the ability to control the full lifecycle of the form and ensure that settings are saved before it is closed. 调出表单可以使开发人员控制表单的整个生命周期,并确保在关闭表单之前保存设置。
So my advice is: 所以我的建议是:
I hope this helps. 我希望这有帮助。 Good luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.