Using Menus

In this section:

How to:

Reference:

The menu control enables you to create a menu bar with pull-down menus in your form. You may create only one menu bar per form.

Using the menu control requires two steps:


Top of page

x
Procedure: How to Place a Menu Bar on Your Form
  1. Click the Menu control Menu control button in the Controls palette.
  2. Draw a rectangle on your form approximately where you want your menu bar to be, at approximately the size you want. You can create a horizontally or vertically aligned menu.
  3. Give your Menu Bar a more meaningful name than MenuBarn (optional).
  4. If necessary, readjust the size and placement of your menu bar.
  5. Double-click the menu bar rectangle or select Properties for the menu control to open the Menu Items dialog box. Specify all the pull-down menus and sub menus you wish to include. For more information on specifying menu items and their associated commands, see How to Create Pull-Down Menus and Submenus.
  6. When all desired menu items have been specified in the Menu Items dialog box, click OK.

Top of page

x
Procedure: How to Create Pull-Down Menus and Submenus

To create a pull-down menu or submenu, complete the following steps from the Menu Items dialog box. This procedure assumes that you have already placed a menu bar on your form. For information on how to place a menu bar on your form, see How to Place a Menu Bar on Your Form.

  1. Double-click the menu bar you have placed on your form in order to access the Menu Items list box.
  2. To create a pull-down menu, click the Add to list button .
  3. Type the name of the pull-down menu as you want it to display on the menu bar in the Text box.
  4. Type the name you want to use to identify the menu bar to your procedure in the Name box.
  5. To create a sub menu, select the name of the pull-down menu to which you are adding the sub menu. Repeat steps 1-3 for each sub menu desired.
  6. Repeat steps 1-4 until all desired pull-down menus and sub menus have been specified in the Menu Items dialog box.
  7. Click OK.
  8. Assign a Click action to the lowest level menu items using the Event Handler editor. You can access the Event Handler editor one of the following ways:
    • Right-click the menu bar and select Edit event handlers from the pop up menu.
    • Select the Events tab in the Properties box and click the Browse button.

    For more information on assigning actions to events, see Defining Events and Event Handlers.



Example: Creating a Menu Bar With Pull-Down Menus and Submenus

The following example demonstrates how to create a pull-down menu that contains submenus.

  1. Select the Menu control from the Controls Palette.
  2. Draw a horizontal rectangle on your form in order to create a horizontal menu bar.

    Creating a Menu Bar image

    Note: You can change the orientation of the menu control by changing the Orientation property in the property sheet.

  3. Double-click the menu bar to open the Menu Items dialog box.
  4. Create menu items on your form by selecting MenuBar1 and clicking the Add button. Type the text you want to appear on the menu bar in the Text box and the name you will use to identify the menu item in the procedure in the Name box.

    Menu Items dialog box

  5. Create submenus by selecting a menu item and clicking the Add button. Type the name you want to give your submenu (for example, Menu5) in the Text box, and type the name you will use to identify the menu item in the procedure in the Name box. When all submenus have been specified, click OK.

    The highest level menu items will appear on your form. Readjust the size and placement of your menu bar if necessary. An arrow on a menu item indicates that the menu item contains submenus.

    Form example

  6. For each lowest level menu item, assign a click action using the Event Handler editor.

For more information on assigning actions to events, see Defining Events and Event Handlers.


Top of page

x
Reference: The Menu Items Dialog Box

You use the Menu Items dialog box to determine the menu items that will appear on your menu bar, including pull-down menus and sub menus.

Menu items dialog box

The Menu Items dialog box contains the following elements:

Text

Enables you to specify the prompt text for each item.

Name

Enables you to specify the name of each item.

Enables you to add a selected item to the list of menu items.

Deletes a selected item from the list of items.

Moves a selected item up in the list of items.

Moves a selected item down in the list of items.


Top of page

x
Changing Menu Bar Properties

When you select your menu control, you will see a list of control properties in the property sheet. Changing these properties will change what your menu bar looks like and what it does at run time.

Many of the styling properties can also be changed using a Cascading Style Sheet. For more information on Cascading Style Sheets, see Using Cascading Style Sheets.

Choose your property based on the task you wish to perform:

If you want to change the name of the menu bar that identifies it to the procedure, use the (Name) Property. For more information, see the (Name) Property.

If you want to change the color of the menu bar, use a style sheet or the ForeColor Property to determine the color of the text in the box. Use the BackColor Property to determine the color of the box.

If you want to add a border to the menu bar, use a style sheet or the Border Property.

If you want to add a border to an individual menu item, use a style sheet or the ItemBorder Property.

If you want to change the size of the location or size of the menu bar, use a style sheet or resize the line directly in the form. You can also use the Bottom Property, Left Property, Right Property, and Top Property.

If you want to change what the cursor looks like when it is on top of the menu bar, use the CursorPointer Property or use a style sheet.

If you want to change the color of the text or the background when the cursor is on top of the menu bar, use the BackColorOver Property and the ForeColorOver Property. You can also use a style sheet.

If you want to make the menu bar inactive or make it invisible, use the Enabled Property to determine whether the is active or not. If the line is inactive, nothing will happen when the end user clicks it. You can also use the Visible Property to determine whether the line is visible to the end user or use a style sheet. For information, see the Enabled Property and the Visible Property.

If you want to assign a help topic to the menu control, use the Help Property. For more information, see Assigning Help to Your Forms and Controls.

If you want to move the menu bar to another layer, use the Layer Property. For more information, see Layering Controls.

If you want to change the alignment of your menu bar from vertical to horizontal, or vice versa, use the Orientation Property.

If you want to display a tooltip when the cursor is on the top of the menu controls, use the ToolTipText Property.


WebFOCUS