ACCELTABLE Statement
Syntax:
ACCELTABLE acceltable-id [mem-option] [code-page]
BEGIN
key-value, command[, accelerator-options]...
.
.
.
END
Description
The ACCELTABLE statement creates a table of accelerators for an application.
An accelerator is a keystroke that gives the user a quick way to choose
a command from a menu or carry out some other task. An accelerator table
can be loaded when needed from the executable file by using the WinLoadAccelTable
function.
You can provide any number of ACCELTABLE statements in a resource script
file. Each statement must specify a unique table identifier. You can provide
any number of accelerator definitions in an accelerator table; however,
no two definitions in a table can specify the same key.
Each accelerator definition must specify a key value and command. The WinSetAccelTable
function used in the application translates the accelerator keystroke into
a WM_COMMAND, WM_HELP, or WM_SYSCOMMAND message that has the corresponding
command value. The message type depends on the accelerator-option field.
acceltable-id
Specifies the accelerator-table identifier.
This value must be an unsigned integer in the range of 1 through 65535,
a simple expression that evaluates to a value in these ranges, or a character
string. Each accelerator table in a resource script file must have a unique
identifier.
mem-option
Specifies how the system manages
the resource when it is in memory. This value must be one of the following:
Option
FIXED
System keeps the resource at a fixed
memory location.
MOVEABLE
System moves the resource as necessary
to compact memory. This is the default option.
DISCARDABLE
System discards the resource if
it is no longer needed.
code-page
key-value
Specifies the character, scan, or
virtual-key code of the accelerator key. The meaning depends on the accelerator-options
field. The key-value field must be a single character enclosed in double-quotation
marks or an integer in the range 0 through 255. If you specify an integer,
you must specify the CHAR, SCANCODE, or VIRTUALKEY accelerator option; otherwise,
the default option is CHAR. Integers must be in decimal or hexadecimal notation.
command
Specifies the command value for the
corresponding WM_COMMAND, WM_HELP, or WM_SYSCOMMAND message. This value
must be a signed integer in the range -32768 through 32767, or a simple
expression that evaluates to an integer in that range.
accelerator-options
Specifies the accelerator
type. This value can be a combination of the following: VIRTUALKEY
Specifies that the key-value field is a virtual-key
code.
SCANCODE
Specifies that the key-value field
is a keyboard scan code.
CHAR
Specifies that the key-value field is
a character code.
SHIFT
Specifies that the user must press the
Shift key and the key corresponding to the key-value field to generate the
accelerator.
CONTROL
Specifies that the user must press
the Ctrl key and the key corresponding to the key-value field to generate
the accelerator.
ALT
Specifies that the user must press the
Alt key and the key corresponding to the key-value field to generate the
accelerator.
LONEKEY
Specifies that the user needs to press
only the key corresponding to the key-value field to generate the accelerator.
SYSCOMMAND
Specifies that the accelerator
translates to a WM_SYSCOMMAND message. If you do not include this option,
the accelerator translates to a WM_COMMAND message.
HELP
Specifies that the accelerator translates
to a WM_HELP message. If you do not include this option, the accelerator
translates to a WM_COMMAND message.
Note: VIRTUALKEY, SCANCODE, and CHAR are mutually exclusive. SYSCOMMAND
and HELP are also mutually exclusive.
Comments
If two accelerators use the same key with different Shift, Control, or ALT
options, you should specify the more restrictive accelerator first in the
table. For example, you should place Shift+Enter before Enter.
If you include the OS2.H header file, you can use the following constants
to specify the accelerator options:
┌────────────────────┬────────────────────┬────────────────────┐│AF_ALT │AF_CHAR │AF_CONTROL │
├────────────────────┼────────────────────┼────────────────────┤
│AF_HELP │AF_LONEKEY │AF_SCANCODE │
├────────────────────┼────────────────────┼────────────────────┤
│AF_SHIFT │AF_SYSCOMMAND │AF_VIRTUALKEY │
└────────────────────┴────────────────────┴────────────────────┘
To combine these constants, you must use the bitwise OR (|) operator.
Example
This example creates an accelerator table whose accelerator-table identifier
is 1. The table contains two accelerators: Ctrl+S and Ctrl+G. These accelerators
generate WM_COMMAND messages with values of 101
and 102, respectively, when the user presses the corresponding keys.
ACCELTABLE 1
BEGIN
"S", 101, CONTROL
"G", 102, CONTROL
END
[Back: Statements]
[Next: ASSOCTABLE Statement]