|
1 | 1 | --- |
2 | 2 | title: "Setting Accelerator Properties (C++)" |
3 | 3 | ms.date: "11/04/2016" |
4 | | -helpviewer_keywords: ["accelerator properties", "properties [C++], accelerator properties", "Type property", "Key property", "Modifier property"] |
| 4 | +helpviewer_keywords: ["accelerator properties", "properties [C++], accelerator properties", "Type property", "Key property", "Modifier property", "VIRTKEY", "Key property", "ID property"] |
5 | 5 | ms.assetid: 0fce9156-3025-4e18-b034-e219a4c65812 |
6 | 6 | --- |
7 | | -# Setting Accelerator Properties |
| 7 | +# Setting Accelerator properties |
8 | 8 |
|
9 | | -You can set accelerator properties in the [Properties window](/visualstudio/ide/reference/properties-window) at any time. You can also use the **Accelerator** editor to modify the accelerator properties in the accelerator table. Changes made using the **Properties** window or the **Accelerator** editor have the same result: edits are immediately reflected in the accelerator table. |
| 9 | +You can set accelerator properties in the [Properties window](/visualstudio/ide/reference/properties-window) at any time. You can also use the [Accelerator editor](../windows/accelerator-editor.md) to modify the accelerator properties in the accelerator table. Changes made using the **Properties** window or the **Accelerator** editor have the same result: edits are immediately reflected in the accelerator table. |
10 | 10 |
|
11 | | -There are three properties for each accelerator ID: |
| 11 | +## ID property |
12 | 12 |
|
13 | | -- The [Modifier property](../windows/accelerator-modifier-property.md) sets control key combinations for the accelerator. |
| 13 | +The **ID** property references each accelerator table entry in program code. This entry is the command value that the program will receive when a user presses the accelerator key or a key combination. To make an accelerator the same as a menu item, make their IDs the same (so long as the ID of the accelerator table is the same as the ID for the menu resource). |
14 | 14 |
|
15 | | - > [!NOTE] |
16 | | - > In the **Properties** window, this property appears as three separate Boolean properties, all of which can be controlled independently: **Alt**, **Ctrl**, and **Shift**. |
| 15 | +There are three properties for each accelerator ID: the **Modifier** property, the **Key** property, and the **Type** property. |
17 | 16 |
|
18 | | -- The [Key property](../windows/accelerator-key-property.md) sets the actual key to use as the accelerator. |
| 17 | +## Modifier property |
19 | 18 |
|
20 | | -- The [Type property](../windows/accelerator-type-property.md) determines whether the key is interpreted as virtual (VIRTKEY) or ASCII/ANSI. |
| 19 | +The **Modifier** property sets control key combinations for the accelerator. |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> In the **Properties** window, this property appears as three separate **Boolean** properties, all of which can be controlled independently: **Alt**, **Ctrl**, and **Shift**. |
| 23 | +
|
| 24 | +The following are legal entries for the **Modifier** property in the accelerator table: |
| 25 | + |
| 26 | + |Value|Description| |
| 27 | + |-----------|-----------------| |
| 28 | + |**None**|User presses only the **Key** value. This value is most effectively used with the ASCII/ANSI values 001 through 026, which is interpreted as ^A through ^Z (**Ctrl+A** through **Ctrl+Z**).| |
| 29 | + |**Alt**|User must press the **Alt** key before the **Key** value.| |
| 30 | + |**Ctrl**|User must press the **Ctrl** key before the **Key** value. Not valid with ASCII Type.| |
| 31 | + |**Shift**|User must press the **Shift** key before the **Key** value.| |
| 32 | + |**Ctrl+Alt**|User must press the **Ctrl** key and the **Alt** key before the **Key** value. Not valid with ASCII Type.| |
| 33 | + |**Ctrl+Shift**|User must press the **Ctrl** key and the **Shift** key before the **Key** value. Not valid with ASCII Type.| |
| 34 | + |**Alt+Shift**|User must press the **Alt** key and the **Shift** key before the **Key** value. Not valid with ASCII Type.| |
| 35 | + |**Ctrl+Alt+Shift**|User must press **Ctrl**, **Alt**, and **Shift** before the **Key** value. Not valid with ASCII Type.| |
| 36 | + |
| 37 | +## Key property |
| 38 | + |
| 39 | +The **Key** property sets the actual key to use as the accelerator. |
| 40 | + |
| 41 | +The following are legal entries for the **Key** property in the accelerator table: |
| 42 | + |
| 43 | + |Value|Description| |
| 44 | + |-----------|-----------------| |
| 45 | + |An integer between 0 and 255 in decimal format.|The value determines whether the value is treated as ASCII or ANSI as follows:<br/><br/>- Single-digit numbers are always interpreted as the corresponding key, rather than as ASCII or ANSI values.<br/>- Values from 1 through 26, when preceded with zeros, are interpreted as ^A through ^Z, which represents the ASCII value of the letters of the alphabet when pressed with the **Ctrl** key held down.<br/>- Values from 27-32 are always interpreted as three-digit decimal values 027 through 032.<br/>- Values from 033 through 255, whether preceded by 0's or not are interpreted as ANSI values.| |
| 46 | + |A single keyboard character.|Uppercase A - Z or the numbers 0 - 9 can be either ASCII or virtual key values; any other character is ASCII only.| |
| 47 | + |A single keyboard character in the range A - Z (uppercase only), preceded by a caret (^) (for example, ^C).|This option enters the ASCII value of the key when it's pressed with the **Ctrl** key held down.| |
| 48 | + |Any valid virtual key identifier.|The drop-down Key box in the Accelerator table contains a list of standard virtual key identifiers.| |
| 49 | + |
| 50 | +> [!NOTE] |
| 51 | +> When entering an ASCII value, the modifier property options are limited. The only control key available for use is the **Alt** key. |
| 52 | +
|
| 53 | +> [!TIP] |
| 54 | +> Another way to define an accelerator key is to right-click an entry or multiple entries in the Accelerator table, choose **Next Key Typed** from the shortcut menu, and then press any of the keys or key combinations on the keyboard. The **Next Key Typed** command is also available from the **Edit** menu. |
| 55 | +
|
| 56 | +## Type property |
| 57 | + |
| 58 | +The **Type** property determines whether the shortcut key combination associated with the accelerator ID is interpreted as an ASCII/ANSI key value or a virtual key (VIRTKEY) combination. |
| 59 | + |
| 60 | +- If the **Type** property is ASCII, the **Modifier** property may only be `None` or `Alt`, or it can have an accelerator that uses the **Ctrl** key (specified by preceding the key with a `^`). |
| 61 | + |
| 62 | +- If the **Type** property is VIRTKEY, any combination of `Modifier` and `Key` values is valid. |
| 63 | + |
| 64 | +> [!NOTE] |
| 65 | +> If you want to enter a value into the accelerator table and have the value be treated as ASCII/ANSI, simply click the **Type** for the entry in the table and select ASCII from the drop down list. However, if you use the **Next Key Typed** command (**Edit** menu) to specify the `Key`, you must change the **Type** property from VIRTKEY to ASCII *before* entering the `Key` code. |
21 | 66 |
|
22 | 67 | ## Requirements |
23 | 68 |
|
24 | 69 | Win32 |
25 | 70 |
|
26 | | -## See Also |
| 71 | +## See also |
27 | 72 |
|
| 73 | +[Editing in an Accelerator Table](../windows/editing-in-an-accelerator-table.md)<br/> |
28 | 74 | [Predefined Accelerator Keys](../windows/predefined-accelerator-keys.md)<br/> |
29 | 75 | [Resource Editors](../windows/resource-editors.md)<br/> |
30 | | -[Accelerator Editor](../windows/accelerator-editor.md) |
|
0 commit comments