<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Activate a command (or tool) by using a .NET context menu in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/activate-a-command-or-tool-by-using-a-net-context/m-p/170503#M4399</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My environment:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Visual Studio 2008&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;VB.NET&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;ArcEngine 9.3.1&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;File Geodatabase&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;I have a .NET Context Menu (right-click) that I have various commands on that have nothing to do with ESRI or any of ArcObjects.&amp;nbsp; Just your ordinary vanilla .NET context menu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to add to this .NET Context Menu, a ToolStripMenuItem that activates an ESRI command (or tool?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Normally that ESRI command (or tool) would be placed on an ESRI toolbar as a button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ESRI command (or tool) I am interested in using has not been placed on any of my ESRI toolbars, nor do I want to.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't care about showing the official ESRI icon for the command or anything, I just want to make the command (or tool) active when I click on the MenuItem on my .NET Context Menu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you point me to how to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on another post, I have gotten this far... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Friend Sub BuildMapContextMenu()
 _mapControlContextMenu.Items.Clear()

 Dim inkToolMenuItem As ToolStripMenuItem = New ToolStripMenuItem("Highlight Tool", Nothing, AddressOf CallInkTool)

 _mapControlContextMenu.Items.Insert(0, inkToolMenuItem)
End Sub

Friend Sub CallInkTool(ByVal sender As Object, ByVal e As System.EventArgs)

 Dim cmd_ As ICommand = New ControlsInkHighlightTool
 cmd_.OnCreate(Me.MapControl.Object)
 cmd_.OnClick()

End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem with this code though is that to tool only appears for a fraction of a second after I click the menu item.&amp;nbsp; I have to click the menu item, and then immediately begin highlighting in order to get it to work.&amp;nbsp; The tool won't remain active between highlights either.&amp;nbsp; As soon as I complete one, it goes back to regular arrow cursor and I have to click the menu item again and immediately begin highlighting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2011 23:45:12 GMT</pubDate>
    <dc:creator>ESRICustomer</dc:creator>
    <dc:date>2011-06-15T23:45:12Z</dc:date>
    <item>
      <title>Activate a command (or tool) by using a .NET context menu</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/activate-a-command-or-tool-by-using-a-net-context/m-p/170503#M4399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My environment:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Visual Studio 2008&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;VB.NET&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;ArcEngine 9.3.1&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;File Geodatabase&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;I have a .NET Context Menu (right-click) that I have various commands on that have nothing to do with ESRI or any of ArcObjects.&amp;nbsp; Just your ordinary vanilla .NET context menu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to add to this .NET Context Menu, a ToolStripMenuItem that activates an ESRI command (or tool?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Normally that ESRI command (or tool) would be placed on an ESRI toolbar as a button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ESRI command (or tool) I am interested in using has not been placed on any of my ESRI toolbars, nor do I want to.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't care about showing the official ESRI icon for the command or anything, I just want to make the command (or tool) active when I click on the MenuItem on my .NET Context Menu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you point me to how to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on another post, I have gotten this far... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Friend Sub BuildMapContextMenu()
 _mapControlContextMenu.Items.Clear()

 Dim inkToolMenuItem As ToolStripMenuItem = New ToolStripMenuItem("Highlight Tool", Nothing, AddressOf CallInkTool)

 _mapControlContextMenu.Items.Insert(0, inkToolMenuItem)
End Sub

Friend Sub CallInkTool(ByVal sender As Object, ByVal e As System.EventArgs)

 Dim cmd_ As ICommand = New ControlsInkHighlightTool
 cmd_.OnCreate(Me.MapControl.Object)
 cmd_.OnClick()

End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem with this code though is that to tool only appears for a fraction of a second after I click the menu item.&amp;nbsp; I have to click the menu item, and then immediately begin highlighting in order to get it to work.&amp;nbsp; The tool won't remain active between highlights either.&amp;nbsp; As soon as I complete one, it goes back to regular arrow cursor and I have to click the menu item again and immediately begin highlighting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 23:45:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/activate-a-command-or-tool-by-using-a-net-context/m-p/170503#M4399</guid>
      <dc:creator>ESRICustomer</dc:creator>
      <dc:date>2011-06-15T23:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Activate a command (or tool) by using a .NET context menu</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/activate-a-command-or-tool-by-using-a-net-context/m-p/170504#M4400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found the problem... I needed to make it the current tool...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Friend Sub BuildMapContextMenu()
 _mapControlContextMenu.Items.Clear()

 Dim inkToolMenuItem As ToolStripMenuItem = New ToolStripMenuItem("Highlight Tool", Nothing, AddressOf CallInkTool)

 _mapControlContextMenu.Items.Insert(0, inkToolMenuItem)
End Sub

Friend Sub CallInkTool(ByVal sender As Object, ByVal e As System.EventArgs)

[INDENT]Dim cmd_ As ICommand = New ControlsInkHighlightTool
cmd_.OnCreate(Me.MapControl.Object)
IMapControl4.CurrentTool = cmd_
cmd_.OnClick()
[/INDENT]
End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:08:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/activate-a-command-or-tool-by-using-a-net-context/m-p/170504#M4400</guid>
      <dc:creator>ESRICustomer</dc:creator>
      <dc:date>2021-12-12T16:08:21Z</dc:date>
    </item>
  </channel>
</rss>

