Share via


Creating Menus, Shortcut Menus, Menu Items, and Submenus

After planning your menu system, you can create it with the Menu Designer. You can create menus, shortcut menus, menu items, submenus of menu items, lines that separate groups of related menu items, and so on. The following sections provide the details.

Creating Menus

You can create menus by customizing the existing Visual FoxPro menu system or by developing your own menu system. To start with the existing Visual FoxPro menu system, use the Quick Menu feature.

To create a menu system with Quick Menu

  1. From the Project Manager, select the Other tab, select Menus, and then select New.

  2. Select Menu.

    The Menu Designer appears.

  3. From the Menu menu, choose Quick Menu.

    The Menu Designer now contains information about the main Visual FoxPro menus.

  4. Customize the menu system by adding or changing menu items.

    For example, insert a Customer menu before the Help menu by choosing the mover button associated with the Help menu, choosing the Insert button, and then typing Customer in the Prompt column. The result looks like this:

    A customized menu system

Tip   Drag mover buttons to change the location of menus on the menu bar. If you need a Help menu, make it the last menu on the menu bar so that users can find it quickly.

Before you can use your menu in an application, you must generate it.

To generate a menu

  • From the Menu menu, choose Generate.

Visual FoxPro prompts you to save the menu system in a file with an .mnx extension. This file is a table that will store all the information about the menu system. After you save the menu system, Visual FoxPro prompts for an output file with an .mpr extension. This file will contain the generated menu program.

Creating Shortcut Menus

Shortcut menus appear when you click the right mouse button on a control or object, and provide a quick way to expose all of the functions that apply to just that object. You can use Visual FoxPro to create shortcut menus, then attach these menus to controls. For example, you can create a shortcut menu containing the commands Cut, Copy, and Paste that will appear when a user right-clicks on data contained in a Grid control.

To create a shortcut menu

  1. From the Project Manager, select the Other tab, select Menus, and then choose New.

  2. Choose Shortcut.

    The Shortcut Designer appears.

When you are in the Shortcut Menu designer, the process for adding menu items is the same as it is for creating menus.

For an example of shortcut menus, run Solution.app in the Visual FoxPro \Samples\Solution\Solution directory.

Creating SDI Menus

SDI menus are menus that appear in single-document interface (SDI) windows. To create an SDI menu you must indicate that the menu will be used on an SDI form while you're designing the menu. Other than that, the process of creating an SDI menu is the same as that for creating a normal menu.

To create an SDI menu

  • While the Menu Designer is open, choose General Options from the View menu, and select Top-Level Form.

Creating Menu Items

After creating menus, you can place menu items on the menus. Menu items can represent Visual FoxPro commands or procedures that you want the user to execute, or menu items can contain submenus that offer additional menu items.

To add menu items to a menu

  1. In the Prompt column, select the menu title to which you want to add menu items.

  2. In the Result box, select Submenu.

    A Create button appears to the right of the list.

  3. Choose the Create button.

    An empty design window appears. In this window, you enter the menu items.

  4. In the Prompt column, type the names of the new menu items.

Creating Submenus

For each menu item, you can create a submenu containing additional menu items.

To create a submenu

  1. In the Prompt column, select the menu item to which you want to add a submenu.

  2. In the Result box, select Submenu.

    A Create button appears to the right of the list. If a submenu already exists, an Edit button appears instead.

  3. Select Create or Edit.

  4. In the Prompt column, type the names of the new menu items.

Adding Menus Programmatically

Though you typically create menus and menu items using the Menu Designer, you can also create them using Visual FoxPro commands. For example, you can create a menu using DEFINE PAD, a submenu using DEFINE POPUP, and items on the submenu using a series of DEFINE BAR commands. You can also use DEFINE BAR to customize menus in such ways as adding pictures, assigning fonts, and displaying messages to the user.

See Also

Menu System Creation | Menu System Design Guidelines | Grouping Menu Items | Designing Menus and Toolbars | Compiling an Application