AnsweredAssumed Answered

Gracefully exiting a custom tool in ArcGIS 9.3.1

Question asked by chaotic42 on Oct 30, 2012
Latest reply on Oct 30, 2012 by chaotic42
I'm having an issue with a tool I've written in C# for an ArcGIS 9.3.1 system. I'm using the ArcGIS Base Tool template and the button works well. When the user clicks on the button, the program brings up the Export Map... dialogue and everything is great. The problem is that if the user cancels out the Export Map... dialogue, the tool stays "pushed down" on the menu bar and the user can no longer click on it. It seems like my program is not gracefully dealing with the user cancelling out of the dialogue.

Here's the code:

public override void OnClick()         {             ICommandItem pCommandItem;             IMxDocument pMxDocument = (IMxDocument)m_application.Document;             ESRI.ArcGIS.esriSystem.UID ExportUID = new ESRI.ArcGIS.esriSystem.UID();             ExportUID.Value = "esriArcMapUI.MxFileMenuItem";             ExportUID.SubType = 9;             pCommandItem = m_application.Document.CommandBars.Find(ExportUID, false, false);             pCommandItem.Execute();         }

I've tried putting the line pCommandItem.Execute(); in a try/catch statement, I've tried disabling and enabling the tool using base.m_enabled=true/false, and nothing seems to work. How can I completely reset the tool after calling pCommandItem.Execute(); so that no matter what the button is reset?