2

I'd like to programmatically execute a command in my ArcGIS Engine application with ArcObjects. I know in Desktop I would do it like this:

ESRI.ArcGIS.Framework.ICommandBars commandBars = m_application.Document.CommandBars;
ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
uid.Value = cmdname; // Example: "esriFramework.HelpContentsCommand" or "{D74B2F25-AC90-11D2-87F8-0000F8751720}"
ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(uid, false, false);
commandItem.Execute();

but IApplication is not available in an Engine environment. Is there an alternative way for standalone (ArcGIS Engine) applications to do this?

1

ESRI have "improved" their forum site and it's now hard to find any of the archived threads but I did find this code fragment in a thread from 2008. I've done very little in Engine so this may be a red herring?

ICommand command = new ControlsZoomToSelectedCommandClass();
command.OnCreate(this.axMapControl1.Object);
command.OnClick();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.