Progress
Programming
Handbook
Static Menu Bars
The following sections describe how to set up a menu bar. They contain sample code that generates the following menu bar.
![]()
Setting Up a Static Menu Bar
Setting up a static menu bar is a three-part process:
The following sections describe this process in greater detail.
Defining Pull-down Submenus
To generate a submenu, you use the DEFINE SUB–MENU statement. Each submenu must have a unique name. Use the MENU–ITEM phrase to specify menu items, and use the LABEL option to define the text for the menu item. If you omit LABEL, Progress displays the item handle name by default. Progress lays out the menu items consecutively in a top-to-bottom order. The following code fragment defines three submenus and their menu items.
The ACCELERATOR option specifies a key or key combination that the user can use to select a menu item without having to pull down the menu. For more information on accelerators, see the "Menu Item Accelerators" section.
The ampersand (&) before the letter x in "E&xit" causes x to be underlined when the menu is displayed. The letter x is called a mnemonic. A mnemonic provides a way to access menu items from the keyboard. For more information on mnemonics, see the "Menu Mnemonics" section.
To generate a help submenu, add the SUB–MENU–HELP phrase to the DEFINE SUB–MENU statement, as shown below.
For more information on the DEFINE SUB–MENU statement, see the Progress Language Reference .
Defining a Menu Bar
To generate a menu bar, you use the DEFINE MENU statement. You must explicitly specify the MENUBAR phrase. You can add menu items and submenus to the menu bar.
In the following code, you assign the three previously defined submenus to the menu bar with the SUB–MENU phrase. You use the LABEL option to define the text for the submenu. Progress lays out the submenus consecutively in left-to-right order on the menu bar.
NOTE: You can add submenus or menu items to existing dynamic menu structures at any time. Progress appends the newly added widgets to the end of the list. See the "Dynamic Menus" section.For more information on the DEFINE MENU statement, see the Progress Language Reference .
Assigning a Menu Bar to a Window
Now that you have set up a menu bar, you need to assign it to a window. You do so by setting the window’s MENUBAR attribute equal to the handle of the menu. For example, if you are using the current window or default window, you can refer to it by using the CURRENT–WINDOW or DEFAULT–WINDOW system handle.
If you are using a window that your application has created, you can refer to the window‘s widget handle. See the following code fragment. At the end of the code, delete the window with the DELETE WIDGET statement.
Example of a Menu Bar with Pull-down Submenus
The
p-bar.p
procedure that follows contains most of the sample definition codes used in the previous sections. The procedure defines a menu bar, mbar, which contains three pull-down submenus. The handle of mbar is assigned to the current window. The ON statements define triggers that execute when you select the corresponding menu items.
When you run this code, you see a menu bar at the top of the window and a frame that displays the name of the first customer. The menu bar contains three titles: Topic, Move, and Exit. You can select each title, one at a time, and pull down its menu to select a menu item.
The Exit menu has only one item. When you choose that item, the procedure ends.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |