ACCELERATORS Statement

Summary: Syntax

acctablenameACCELERATORS
BEGIN
event, idvalue[[,type]] [[NOINVERT]] [[ALT]] [[SHIFT]] [[CONTROL]]
.
.
.
END

The ACCELERATORS statement defines one or more accelerators for an application. An accelerator is a keystroke defined by the application to give the user a quick way to perform a task. The TranslateAccelerator function is used to translate accelerator messages from the application queue into WM_COMMAND or WM_SYSCOMMAND messages.

The acctablename field specifies either a unique name or an integer value that identifies the resource.

The event field specifies the keystroke to be used as an accelerator. It can be any one of the following:

" char "

A single ASCII character enclosed in double quotation marks. The character can be preceded by a caret (^), meaning that the character is a control character.

ASCII character

An integer value representing an ASCII character. The type field must be ASCII.

Virtual key character

An integer value representing a virtual key. The virtual key for alphanumeric keys can be specified by placing the uppercase letter or number in double quotation marks (for example, "9" or "C"). The type field must be VIRTKEY.

The idvalue field specifies an integer that identifies the accelerator.

The type field is required only when event is an ASCII character or a virtual key character. The type field specifies either ASCII or VIRTKEY; the integer value of event is interpreted accordingly. When VIRTKEY is specified and the event field contains a string, the event field must be uppercase.

The NOINVERT option, if given, means that no top-level menu item is high-lighted when the accelerator is used. This is useful when defining accelerators for actions such as scrolling that do not correspond to a menu item. If NOINVERT is omitted, a top-level menu item will be highlighted (if possible) when the accelerator is used.

The ALT option, if given, causes the accelerator to be activated only if the ALT key is down.

The SHIFT option, if given, causes the accelerator to be activated only if the SHIFT key is down.

The CONTROL option, if given, defines the character as a control character (the accelerator is only activated if the CTRL key is down). This has the same effect as using a caret (^) before the accelerator character in the event field.

The ALT, SHIFT, and CONTROL options apply only to virtual keys.

The following example demonstrates the correct usage of accelerator keys:

1 ACCELERATORS

BEGIN

“^C”, IDDCLEAR ; control C

“K”, IDDCLEAR ; shift K

“k”, IDDELLIPSE, ALT ; alt K

98, IDDRECT, ASCII ; b

66, IDDSTAR, ASCII ; B (shift b)

“g”, IDDRECT ; g

“G”, IDDSTAR ; G (shift G)

VK_F1, IDDCLEAR, VIRTKEY ; F1

VK_F1, IDDSTAR, CONTROL, VIRTKEY ; control F1

VK_F1, IDDELLIPSE, SHIFT, VIRTKEY ; shift F1

VK_F1, IDDRECT, ALT, VIRTKEY ; alt F1

VK_F2, IDDCLEAR, ALT, SHIFT, VIRTKEY ; alt shift F2

VK_F2, IDDSTAR, CONTROL, SHIFT, VIRTKEY ; ctrl shift F2

VK_F2, IDDRECT, ALT, CONTROL, VIRTKEY ; alt control F2

END