Engine sketch context menu.
Product Availability
Description
The CLSID of this menu is: {4F29BC92-2988-45E8-8317-0169EAB954C6}.
This menu works with the ToolbarControl, PageLayoutControl and MapControl.
If the ArcGIS Engine application using this menu is initialized with an ArcGIS Engine Runtime license or an ArcView license, this menu can be used to edit shapefiles and personal geodatabases.
If the ArcGIS Engine application using this menu is initialized with an ArcGIS Engine GeoDatabase Editing license, or ArcEditor or ArcInfo, this menu can be used to edit data within an enterprise geodatabase.
Interfaces
Interfaces | Description |
---|---|
IMenuDef (esriSystemUI) | Provides access to members that define a menu. |
Remarks
This menu can only be used as a pop up menu or context menu. Create a new ToolbarMenu and add this predefined ControlsEditingSketchContextMenu to it using the IToolbarMenu::AddItem method. To display the ToolbarMenu as a right click context menu use the IToolbarMenu::PopupMenu method.
To enable the accelerator keys on this context menu complete the following steps:
- Set the Form property KeyPreview to be True.
- Translate the specified KeyCode using the ICommandPool2::TranslateAcceleratorKey in the Form_KeyDown.
- If you want the accelerator keys to be recognized without displaying the ControlsEditingSketchContextMenu then create each command in the IToolbarMenu::CommandPool using the code below.
private
IToolbarMenu m_ToolbarMenu;private void
MainForm_Load(object
sender, EventArgs e) {//Create a new ToolbarMenu
m_ToolbarMenu =new
ToolbarMenu();//Share the ToolbarControl's command pool
m_ToolbarMenu.CommandPool = axToolbarControl1.CommandPool;//Set the hook to the MapControl
m_ToolbarMenu.SetHook(axMapControl1);//Add commands to the ToolbarMenu
m_ToolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0,false
, esriCommandStyles.esriCommandStyleTextOnly);//Create each command on the ToolbarMenu so that the Accelerator Keys are recognized.
//Alternatively the user must popup the menu before using the Accelerator Keys
long
itemCount = m_ToolbarMenu.CommandPool.Count;for
(int
i = 0; i < itemCount; i++) { ICommand pCommand = m_ToolbarMenu.CommandPool.get_Command(i); pCommand.OnCreate(m_mapControl); } }private void
MainForm_KeyDown(object
sender, KeyEventArgs e) { ICommandPool2 pPool2; pPool2 = m_ToolbarMenu.CommandPoolas
ICommandPool2; pPool2.TranslateAcceleratorKey((int
)e.KeyCode); }private void
axMapControl1_OnMouseUp(object
sender, IMapControlEvents2_OnMouseUpEvent e) {if
(e.button == 2) m_ToolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); }
Private
m_ToolbarMenuAs
IToolbarMenuPrivate Sub
MainForm_Load(ByVal
senderAs
System.Object,ByVal
eAs
EventArgs)Handles
MyBase.Load'get the MapControl
m_mapControl =CType
(axMapControl1.Object, IMapControl3)'disable the Save menu (since there is no document yet)
menuSaveDoc.Enabled =False
'Create a new ToolbarMenu
m_ToolbarMenu =New
ToolbarMenu()'Share the ToolbarControl's command pool
m_ToolbarMenu.CommandPool = axToolbarControl1.CommandPool'Set the hook to the MapControl
m_ToolbarMenu.SetHook(axMapControl1)'Add commands to the ToolbarMenu
m_ToolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0,False
, esriCommandStyles.esriCommandStyleTextOnly)'Create each command on the ToolbarMenu so that the Accelerator Keys are recognized. Alternatively
'the user must popup the menu before using the Accelerator Keys
Dim
itemCountAs Integer
itemCount = m_ToolbarMenu.CommandPool.CountDim
iAs Integer For
i = 0To
itemCount - 1Dim
pCommandAs
ICommand pCommand =CType
(m_ToolbarMenu.CommandPool.Command(i), ICommand) pCommand.OnCreate(m_mapControl)Next End Sub Private Sub
axMapControl1_OnMouseUp(ByVal
senderAs
System.Object,ByVal
eAs
ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseUpEvent)Handles
axMapControl1.OnMouseUpIf
(e.button = 2)Then
m_ToolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd)End If End Sub Private Sub
MainForm_KeyDown(ByVal
senderAs
System.Object,ByVal
eAs
System.Windows.Forms.KeyEventArgs)Handles
MyBase.KeyDownDim
pPool2As
ICommandPool2 pPool2 =CType
(m_ToolbarMenu.CommandPool, ICommandPool2) pPool2.TranslateAcceleratorKey(e.KeyCode)End
Sub