This document is archived and information here might be outdated. Recommended version. |
Adds a new accelerator to the accelerator table.
[Visual Basic .NET]
Public Function Add ( _
ByVal ID As Object, _
ByVal Key As Integer, _
[ByVal bCtrl As Boolean], _
[ByVal bAlt As Boolean], _
[ByVal bShift As Boolean] _
) As Boolean
[C#]
public bool Add (
object ID,
int Key,
bool bCtrl,
bool bAlt,
bool bShift
);
ID specifies the unique identifier of the command that this accelerator activates. For built-in commands, use the UID. For VBA macros and UIControls, use a string representing the full name of the command.
Key specifies the keycode used for this accelerator. Use the Visual Basic Key Code constants for the value of Key.
bCtrl Use True if the Ctrl key is one of the keys used in the accelerator; otherwise use False.
bAlt Use True if the Alt key is one of the keys used in the accelerator; otherwise use False.
bShift Use True if the Shift key is one of the keys used in the accelerator; otherwise use False.
In VBA, you can use the builtin ArcID module to find the unique identifier for a particular command.
In the following example, the keyboard accelerator CTRL+A is assigned to the built-in ArcMap Add Data command. You would get m_app from the hook in ICommand::OnCreate() .
IAcceleratorTable pAccTable = m_app.Document.Accelerators;
UID uid = new UIDClass();
uid.Value = "{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}";
bool addedAcc = pAccTable.Add(uid, System.Convert.ToInt32(System.Windows.Forms.Keys.A), true, false, false) ;
Dim pAccTable As IAcceleratorTable = m_app.Document.Accelerators
Dim uid As UID = New UIDClass()
uid.Value = "{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}"
Dim addedAcc As Boolean = pAccTable.Add(uid, System.Convert.ToInt32(System.Windows.Forms.Keys.A), True, False, False)