Defining Menus

Menus

The high level Menu element of the ARC file format is a menu bar that can be referenced by a high level Window.

A menu consists of a list of pull-down command options accessed from the menu bar. The following lists the mandatory properties for menus:

 

Menu resource-id
Begin
Menu-item menu-id "title" {accelerator-key}
...
End

The following describes the menu properties:

Property

Description 

menu

Identifies the resource as a menu. (Specified once only.) 

resource-id

Resource ID number. It must be an integer between 1 and 32767. (Specified once only.) 

Menu-item

Identifies the resource as a menu item. (Specified for each menu item.) 

menu-id

Menu ID number. It must be an integer between 1 and 32767. (Specified for each menu item.) 

"title"

Title of the menu item, contained in quotation marks. (Specified for each menu item.) 

accelerator-key

Optional key combination settings that provide quick access to commands.  

Menu Items

Menu items defined between begin and end statements are positioned on the same level. Submenus positioned between begin and end statements are positioned on the next level.

Menu-item 100 "A title"
Menu-item 100 "A title" $4065$
Menu-item 100 "A title"
begin
checked
end

Menu-item 100 "A title"
Begin
disabled
checked
end

Menu-item 100 "A title"
Begin
Not disabled
Not checkable
end

Menu-item 100 "file"
Begin
Not disabled
Menu-item 110 "open" $4065$
Menu-item 120 "print" $4066$
Begin
Menu-item 130 "by page

Separator
Menu-item 140 "by chapter"
end
Not checkable
Menu-item 150 "close"
end

The following table shows all optional properties for a menu item along with the default values used if the properties are omitted.

Accelerators

The menu item accelerator element of a menu item is a numeric literal that specifies a key or multiple keys that equate to the menu item. The numeric to use for an accelerator is derived by starting with a base numeric that specifies a single key then adding a specific number for any modifier keys desired (control, alt, or shift.) The base numeric for all printable characters is its ASCII value. This can be indicated in an ARC file via a character literal. For an uppercase A, the character literal is 'A'. For keys with non-printable characters and keypad keys, the following table shows character codes to use as the base numeric:

 

KEY_UP_ARROW

$012d$

KEY_DOWN_ARROW

$012e$

KEY_RIGHT_ARROW

$012f$

KEY_LEFT_ARROW

$0130$

KEY_PAGE_UP

$0131$

KEY_PAGE_DOWN

$0132$

KEY_HOME

$0135$

KEY_END

$0136$

KEY_INSERT

$0138$

KEY_BACKTAB

$013b$

KEY_KEYPAD_0

$01be$

KEY_KEYPAD_1

$013f$

KEY_KEYPAD_2

$0140$

KEY_KEYPAD_3

$0141$

KEY_KEYPAD_4

$0142$

KEY_KEYPAD_5

$0143$

KEY_KEYPAD_6

$0144$

KEY_KEYPAD_7

$0145$

KEY_KEYPAD_8

$0146$

KEY_KEYPAD_9

$0147$

 

 

KEY_F1

$014b$

KEY_F2

$014c$

KEY_F3

$014d$

KEY_F4

$014e$

KEY_F5

$014f$

KEY_F6

$0150$

KEY_F7

$0151$

KEY_F8

$0152$

KEY_F9

$0153$

KEY_F10

$0154$

KEY_F11

$0155$

KEY_F12

$0156$

KEY_KEYPAD_STAR

$0174$

KEY_KEYPAD_PLUS

$0175$

KEY_KEYPAD_MINUS

$0176$

KEY_KEYPAD_SLASH

$0177$

Once the base numeric is established, either an ASCII value or one of the special values listed above, it can be added to any or all of these three modifiers.

SHIFT

$1000$

CONTROL

$2000$

ALT

$4000$

Some examples of accelerator numeric literals are:

$41$

(uppercase A)

$1041$

(shift-uppercase A)

$2041$

(control-uppercase A)

$4041$

(alt-uppercase A)

$6041$

(control-alt-uppercase A)

$7041$

(control-alt-shift-uppercase A)

Menu Bars

This section provides the mandatory properties for menu bars, menus, and menu items. Additionally, it provides sample files to illustrate resource file menu definitions.

The Resource Properties Index identifies and describes the optional properties for all resources contained in this section.

Menu bars are either assigned as placeholders for which menus can be created at runtime, or are directly or indirectly defined within the resource file.

Default Menu Bars

The default menu bar serves as a placeholder for which menus can be created at runtime through a standard section of code and is defined as follows:

Menubar Default

Directly- and Indirectly-Defined Menu Bars

The following describes the differences between directly-defined and indirectly-defined menu bars:

  • Definitions for directly-defined menu bars are listed within the nested structure of top-level windows. Directly-defined menu bars do not need menu ID numbers because they cannot be shared with other windows.

  • Definitions for indirectly-defined menu bars consist of two components: a menu bar definition that is a separate top-level resource, and a reference within the nested structure of the top-level window that points to the definition. Indirectly-defined menu bars can be shared with other windows.

Directly-Defined Menu Bars

The following lists the mandatory properties for directly-defined menu bars:

Menubar
Begin
 ...
End

The following describes the menu bar properties:

Property

Description

Menubar

Identifies the resource as a menu. Directly-defined menu bars do not require ID numbers.

Indirectly-Defined Menu Bars

As described above, indirectly-defined menu bar definitions are comprised of two components. The following lists the mandatory properties for the reference component of indirectly-defined menu bars:

Menubar menu-resource-id

The following describes the menu bar properties:

Property

Description

Menubar

Identifies the resource as a menu bar.

menu-resource-id

Menu resource ID.

The following lists the mandatory properties for the definition component of indirectly-defined menu bars:

Menu menu-resource-id

The following describes the menu bar properties:

Property

Description

Menu

Identifies the resource as a menu bar.

menu-resource-id

Menu resource ID.

Menus

A menu consists of a list of pull-down command options accessed from the menu bar. The following lists the mandatory properties for menus:

Menu resource-id
Begin
 Menu-item menu-id"title" {accelerator-key}
...
End

The following describes the menu properties:

Property

Description

Menu

Identifies the resource as a menu. (Specified once only.)

resource-id

Resource ID number. It must be an integer between 1 and 32767. (Specified once only.)

Menu-item

Identifies the resource as a menu item. (Specified for each menu item.)

menu-id

Menu ID number. It must be an integer between 1 and 32767. (Specified for each menu item.)

"title"

Title of the menu item, contained in quotation marks. (Specified for each menu item.)

accelerator-key

Optional key combination settings that provide quick access to commands.

Menu items defined between begin and end statements are positioned on the same level. Submenus positioned between begin and end statements are positioned on the next level.

Accelerator Keys

Accelerator keys are key combinations that provide quick access to commands. Although accelerator key settings are optional, they are defined on the mandatory properties line of a menu. To specify the text of the accelerator key, separate the text of the menu item and the accelerator label with a tab character in the title.

Accelerator keys can also be defined by using regular characters enclosed in single quotation marks. The modifiers <Ctrl>,<Alt>, and <Shift> can be used with either method.

Key(s)

Hex Code

Character Code

Ctrl+F

$2066$

<Ctrl> + 'f'

F1

$014B$ or KEY_F1

none

<Up Arrow>

$012D$ or KEY_UP_ARROW

none

Shift+6

$1036$ or $005E$

<Shift> + '6' or '^'

Alt+X

$4078$

<Alt> + 'x'

Ctrl+Alt+Shift+6

$7036$ or $605E$

<Ctrl> + <Alt> + <Shift> + '6' or <Ctrl> + <Alt> + '^'

The following example defines a menu item with an ID of 10001, a title of "Open", and accelerator keys of Ctrl+O.

Menu-item 10001 "&Open..." "\tCtrl+O" ctrl+'o'

Menu items that are defined between begin and end statements are positioned on the same level. Submenus are positioned on the next level.

Separators

Separators are denoted by the word SEPARATOR where a menu item would be placed.

DY>