Defining Menus
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. |
Example
The following example contains three windows. Window 2 contains a directly-defined menu bar. Window 3 contains an indirectly-defined menu bar. Window 4 contains a default menu bar that is empty and serves as a placeholder.
version "3.0"
window 2 "Second window" 3 13 200 100 begin
eventmask EM_ALL
menubar begin //Directly-defined menu bar
menu-item 1001 "&File" begin
menu-item 1011 "&Open"
menu-item 1012 "&Save"
menu-item 1013 "E&xit"
end
menu-item 1002 "&Edit" begin
menu-item 1021 "&Cut"
menu-item 1022 "C&opy"
menu-item 1023 "&Paste"
end
end
end
window 3 "Third window" 10 20 200 100
begin
menubar 1000 //Indirectly-defined menu bar reference
button 1 "OK" 10 10 50 25
checkbox 2 "Done" 10 10 50 25
end
window 4 "Forth window" 10 20 200 100
begin
menubar default //sets menu status for this window
button 1 "OK" 10 10 50 25
checkbox 2 "Done" 10 10 50 25
end
menu 1000 begin //Indirectly-defined menu bar definition
menu-item 1001 "&File"
begin
menu-item 1011 "&Open"
menu-item 1012 "&Save"
separator
menu-item 1013 "E&xit"
end
menu-item 1002 "&Edit"
begin
menu-item 1020 "&Undo"
separator
menu-item 1021 "&Cut"
menu-item 1022 "C&opy"
menu-item 1023 "&Paste"
end
menu-item 1003 "&Options"
begin
menu-item 1031 "&Disabled" begin disabled end
menu-item 1032 "&CheckMe" begin checkable end
menu-item 1033 "&ImChecked" begin checkable checked end
end
end
menu 2000
begin
menu-item 1001 "&File"
begin
menu-item 1011 "&Open"
begin
menu-item 1012 "&Save"
begin
menu-item 1013 "&Save As"
begin
menu-item 1014 "&Restore"
begin
menu-item 1015 "&Restore As"
begin
menu-item 1016 "&Print"
begin
menu-item 1017 "&Print Setup"
begin
menu-item 1018 "&Oops"
begin
menu-item 1019 "&Exit"
end
end
end
end
end
end
end
end
menu-item 1113 "E&xit"
end
end
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.
>