Catch ArcMap Closing Event

2226
4
08-05-2010 07:03 AM
ChrisKeefer
New Contributor
Hi All,
I'm writing an ArcMap extension in which the user can potentially launch some long running processes. For that reason I'd like to be notified when the user tries to close ArcMap so I can throw up a dialog that asks them to confirm that they really want to close, not waiting for the long running process to complete.

I tried using the BeforeCloseDocument event but that also gets fired when you open a new document. I just want to know when the application is going down. Does anyone know a way to do this?

Thanks,
Chris
0 Kudos
4 Replies
vincentLahaye
New Contributor II
If you are using your own extension, you should have something like that :

http://resources.esri.com/help/9.3/arcgisdesktop/com/COM/VB6/scenarios/dtop_extensions.htm

You will find a shutdown method.  When Arcmap is closing, this method is called.

Vincent
0 Kudos
ChrisKeefer
New Contributor
Thanks for the reply Vincent. The problem is that I want to be able to stop ArcMap from closing, similar to returning true in the IDocumentEvents.BeforeCloseDocument event. So when the user clicks the 'x' or File-->Close I'd like to catch the event so I can warn the user that there is a process running that will be killed if they close ArcMap. If they decide they don't want to close ArcMap, I'll eat the event (like returning true above) and ArcMap will stay open.

-Chris
0 Kudos
vincentLahaye
New Contributor II
You should do this in the ICustomizationFilter class.  This class get all click in ArcMap.  If your user click on Close buton, this class is fire, and you can decide what you want to do with this command.  You can stop the command, send a forms, all you want. 

That's work fine for File/close ,  but not for "X".  "X" seems to be a little bit different. 

Hope it can help you a little bit.

Vincent
0 Kudos
vincentLahaye
New Contributor II
I found a thread about your problem with my solution.  The X problem seem to be a real problem.

http://forums.esri.com/Thread.asp?c=93&f=982&t=215177

Vincent
0 Kudos