Visual Studio 2010 确认关闭 [英] visual studio 2010 confirmation on close

查看:37
本文介绍了Visual Studio 2010 确认关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 VS2010 在我关闭整个环境时询问我是否确定关闭 VS2010.

I want VS2010 to ask me when I am closing the whole environment whether I am sure about closing VS2010 or not.

很遗憾我在任何地方都找不到此设置

Unfortunately I couldn't find this setting anywhere

有人知道吗?

推荐答案

我还没有在 Visual Studio 2010 中尝试过这个,但是您至少可以通过使用自动化宏在 Visual Studio 2008 中实现这一点.以下说明适用于 2008 年,应该不会太难翻译到 2010 年(希望如此).

I haven't tried this in Visual Studio 2010, but you can achieve this in Visual Studio 2008 at least by using an Automation Macro. The instructions below work for 2008, and shouldn't be too hard to translate to 2010 (hopefully).

打开宏 IDE (Tools->Macros->MacroIDE),在宏列表中你应该看到一个条目 EnvironmentEvents.双击它以获取包含现有环境事件宏的模块.

Open up the Macro IDE (Tools->Macros->MacroIDE), and in the list of Macros you should see an item EnvironmentEvents. Double-click this to get a module containing the existing Environment Event macros.

在下拉列表中选择SolutionEvents,然后在声明列表中选择QueryCloseSolution.我们正在做的是创建一个宏,每当您尝试关闭解决方案时都会运行该宏.我们将创建一个消息框来询问用户是否真的想要这样做,并可以选择取消关闭——你应该得到这样的结果:

In the drop-down list select SolutionEvents, and then in the Declarations list select QueryCloseSolution. What we're doing is creating a macro that is run whenever you try to close a Solution. We'll create a messagebox to ask the user if they really want to do it, and optionally cancel the shutdown - you should end up with something like this:

Private Sub SolutionEvents_QueryCloseSolution(ByRef fCancel As Boolean) Handles SolutionEvents.QueryCloseSolution
    If (MsgBox("Close the solution?", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel) Then fCancel = True
End Sub

保存宏项目,然后尝试关闭解决方案或关闭 Visual Studio.如果星星对齐,您将看到一个确认消息框.如果点击取消",解决方案不会关闭,VS也不会关闭.

Save the Macro project, and try closing the solution, or shutting down Visual Studio. If the stars are aligned you'll see a confirmation message box. If you click "Cancel", the solution won't close, and VS won't shut down.

现在,也许有人可以在评论中确认这是否适用于 VS2010?

Now, perhaps someone can confirm in the comments if this works for VS2010?

这篇关于Visual Studio 2010 确认关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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