Solved! Go to Solution.
public abstract class RollbackableToolBase : BaseTool { protected IApplication m_Application = null; public ICommandItem RollbackTool { get; set; } public override sealed void OnCreate(object hook) { m_Application = hook as IApplication; } } public class RollbackableTool1 : RollbackableToolBase { public RollbackableTool1 () { Result = null; } // the shoot event public event RanEventHandler Ran= null; public object Result { get; private set; } public override void OnMouseDown(int button, int shift, int x, int y) { // interact with the screen and get the result // restore the current tool m_Application.CurrentTool = this.RollbackTool; } } public delegate void RanEventHandler(object sender, EventArgs e);
Are you using Visual Studio? There are templates in VS to create custom tools for ArcMap. You can create them as COM extensions (need an installer to deploy) or using the newer Add-in framework. I recommend the Add-in method because it makes deployment much easier. It looks like your code is attempting to use the COM method. There is a lot more to it than what you have and yes it has to be registered. Do you have the template?
So is it working ok now? You seem to be doing it right. Use the template to build the ITool, then hide it from the toolbar. Because it is a COM tool you can access it by the GUID. It doesn't need to be re-registered at runtime. It gets registered when it is installed. Then it is available to you when ArcMap starts via the GUID.