Creating an Accelerator Table Resource

Create an accelerator-table resource by using the ACCELERATORS statement in your resource-definition file. You must assign a name or a resource identifier to the accelerator table, preferably unlike that of any other resource. Windows CE uses this identifier to load the resource at run time.

Each accelerator you define requires a separate entry in the accelerator table. In each entry, you define the keystroke that generates the accelerator and the accelerator's identifier. The keystroke is either an ASCII character code or virtual-key code. You must also specify whether the keystroke must be used in some combination with the alt, shift, or ctrl keys.

An ASCII keystroke is specified either by enclosing the ASCII character in double quotation marks or by using the integer value of the character in combination with the ASCII flag. The following code examples show how to define ASCII accelerators.

"A",   ID_ACCEL1         ; SHIFT+A 
65,    ID_ACCEL2, ASCII  ; SHIFT+A 
 

A keystroke that generates a virtual-key code is specified differently depending on whether the keystroke is an alphanumeric key or a non-alphanumeric key. For an alphanumeric key, the key's letter or number, enclosed in double quotation marks, is combined with the VIRTKEY flag. For a non-alphanumeric key, the Windows virtual-key code for the specific key is combined with the VIRTKEY flag. The following code examples show how to define virtual-key code accelerators.

"a",         ID_ACCEL3, VIRTKEY   ; A (caps-lock on) or a 
VK_INSERT,   ID_ACCEL4, VIRTKEY   ; INSERT key 
 

If you want the user to press the alt, shift, or ctrl keys in some combination with the accelerator keystroke, specify the ALT, SHIFT, and CONTROL flags in the accelerator's definition. The following code examples show possible combinations.

"B",   ID_ACCEL5, ALT                     ; ALT_SHIFT+B 
"I",   ID_ACCEL6, CONTROL, VIRTKEY        ; CTRL+I 
VK_F5, ID_ACCEL7, CONTROL, ALT, VIRTKEY   ; CTRL+ALT+F5