Ivo6070

Hi

I have an addin that lets the user edit some data in a tool window. When the user shuts down VS I want to pop up a message box "Do you want to save your change Yes/No/Cancel". Ideally, Cancel should stop the shutdown process.

How do I do that

Thanks

Ivo



Re: Visual Studio Extensibility Stop VS shutdown

Carlos Quintero - MVP

You could use DTE.Events.CommandEvents to capture the BeforeExecute event of the "File.Exit" command but if the user clicks the "X" button of the IDE window, you won't get a notification.

Your add-in can be notify when it is unloaded and the reason (such as VS closing) using the OnDisconnection method, but I think that you can't really prevent VS closing.






Re: Visual Studio Extensibility Stop VS shutdown

Ivo

From OnBeginShutdown docs: http://msdn2.microsoft.com/en-us/library/extensibility.idtextensibility2.onbeginshutdown(VS.80).aspx

"Although a shutdown of Visual Studio might be canceled, the OnBeginShutdown method cannot be canceled."

But it doesn't say how to cancel a shutdown. I can try subclassing the main window and handle WM_CLOSE, but somehow I think that's not what they had in mind.





Re: Visual Studio Extensibility Stop VS shutdown

Carlos Quintero - MVP

The OnBeginShutdown is a pretty useless method and won't help you at all.

I don't think there is a way for an add-in to cancel a VS shutdown other than subclassing DTE.MainWindow and intercepting such messages.