Progress
Programming
Handbook


Dynamic Menu Bar

The following sections contain steps on how to set up a dynamic menu bar, as well as a sample code that generates the following menu bar and pull-down menu.

Setting Up a Dynamic Menu Bar

Setting up a dynamic menu bar is a three-part process:

  1. Create the menu bar and assign it to a window.
  2. Create submenus and attach them as children to the parent menu or to another submenu.
  3. Create menu items and attach them to the submenu(s).

The following sections describe this process in detail.

Creating the Menu Bar

Recall that when you define a static menu widget (for example, a menu bar) you use the DEFINE MENU statement and you must specify the MENUBAR attribute. Without the MENUBAR attribute, Progress automatically treats the widget as a pop-up menu. For a dynamic menu, the POPUP–ONLY attribute determines whether it is a menu bar or a pop-up menu. To create a dynamic menu bar, you must do the following:

  1. Define a variable for the menu as a widget–handle.
  2. Use the CREATE MENU statement to create a menu widget. The POPUP–ONLY attribute defaults to FALSE, so the menu is treated as a menu bar.
  3. To display the menu bar, attach it to a window. Set the MENUBAR attribute of the window equal to the widget handle of the menu.

The following code fragment defines a widget-handle variable, creates a dynamic menu, and sets the MENUBAR attribute of the current window to main–bar–ptr.

DEFINE VARIABLE main-bar-ptr  AS WIDGET-HANDLE.
        .
        .
        .
CREATE MENU main-bar-ptr.

CURRENT-WINDOW:MENUBAR = main-bar-ptr. 

Creating Submenus

To create a submenu, you use the CREATE SUB–MENU statement. Each submenu must have a unique label. Use the ASSIGN clause of the CREATE SUB–MENU statement to set the PARENT attribute equal to the widget handle of the menu or another submenu. You cannot change the parent of submenus or menu items once you make the assignment. The only way you can change the parent/child relationship is by deleting the child. Use the LABEL option to define the text for the submenu.

Progress lays out dynamic menu widgets the same way it does static menu widgets. Submenus are laid out consecutively in a left-to-right order on the menu bar; menu items are laid out consecutively in a top-to-bottom order. If the application deletes a dynamic submenu or menu item widget, Progress automatically shifts remaining widgets up or to the left. For example, when a menu item is deleted, the remaining items are shifted up to fill the previously occupied space. You can add submenus or menu items to existing menu structures at any time. Progress appends the newly added widgets to the end of the list.

The following code fragment creates a submenu srep–men–ptr and sets the parent attribute to main–bar–ptr. The label of the submenu is Reps.

CREATE SUB-MENU srep-men-ptr
  ASSIGN PARENT = main-bar-ptr
  LABEL = "Reps". 

Creating Menu Items

Recall that when you create a menu item for a static menu widget, you use the MENU–ITEM phrase to specify the menu item. However, for a dynamic menu, you must first define the widget-handle variables, then use the CREATE MENU–ITEM statement to create each individual menu item. Each menu item can be used in only one menu or submenu. Use the ASSIGN clause of the CREATE MENU–ITEM statement to set the PARENT attribute of the menu item equal to the widget handle of the menu or submenu. Use the LABEL option to define the text for the menu item.

The following code fragment creates a menu item temp–hand–ptr, which is set to the parent attribute of a previously defined submenu srep–menu–ptr. The label of the menu item is salesrep.rep–name.

CREATE MENU-ITEM  temp-hand-ptr
  ASSIGN PARENT = srep-men-ptr
    LABEL = salesrep.rep-name 

Each MENU–ITEM widget can be one of four different subtypes:

The default subtype is NORMAL, and only the first two subtypes—NORMAL and READ–ONLY—have labels.

You must set the subtype before Progress realizes the menu item. Enter the subtype in uppercase and in quotes, as shown in the following code fragment.

CREATE MENU-ITEM  temp-hand-ptr
    ASSIGN SUBTYPE = "RULE"
        PARENT = srep-men-ptr. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095