DEFINE MENU Command

Example   See Also

Creates a menu bar.

Syntax

DEFINE MENU MenuBarName
  [BAR [AT LINE nRow]]
  [IN [WINDOW] WindowName | IN SCREEN]
  [FONT cFontName [, nFontSize]]
  [STYLE cFontStyle]
  [KEY KeyLabel]
  [MARK cMarkCharacter]
  [MESSAGE cMessageText]
  [NOMARGIN]
  [COLOR SCHEME nSchemeNumber
  | COLOR ColorPairList]

Arguments

MenuBarName

Specifies the name of the menu bar to create. The menu bar name allows you to reference the menu bar in other commands and functions.

BAR [AT LINE nRow]

Creates a menu bar that behaves like the Visual FoxPro system menu bar. The menu bar has these characteristics:

IN [WINDOW] WindowName

Places a menu bar in a user-defined window. Specify the name of the window in which you want to place the menu bar with WindowName. If you omit IN WINDOW, the menu bar is placed in the main Visual FoxPro window by default unless there is an active user-defined window. If there is an active user-defined window, the menu bar is placed in the active window.

IN SCREEN

Explicitly places the menu bar in the main Visual FoxPro window.

FONT cFontName [, nFontSize]

Specifies a default font for all menu titles in the menu bar. You can override the default font for an individual menu title by including the FONT clause in DEFINE PAD.

cFontName specifies the name of the font, and nFontSize specifies the point size. For example, the following command creates a menu bar with menu titles in 12-point Courier font:

DEFINE MENU mnuExample FONT 'Courier', 12

If the font you specify is not available, a font with similar font characteristics is substituted. If you include the FONT clause but omit the point size nFontSize, a 10-point font is used.

The FONT clause is ignored for menu titles added to the Visual FoxPro system menu _MSYSMENU. Note that the Menu Designer uses the Visual FoxPro system menu.

STYLE cFontStyle

Specifies a default font style for all the menu titles in the menu bar. You can override the default style for individual menu titles by including the STYLE clause in DEFINE PAD.

If you omit the STYLE clause, or if the font style you specify is not available, the Normal font style is used.

The font styles you can specify with cFontStyle are as follows:

Character Font style
B Bold
I Italic
N Normal
Q Opaque
- Strikeout
T Transparent
U Underline

You can include more than one character to specify a combination of font styles. For example, the following command specifies Bold Italic:

DEFINE MENU mnuExample STYLE 'BI'

The STYLE clause is ignored for menu titles added to the Visual FoxPro system menu _MSYSMENU. The Menu Designer uses the Visual FoxPro system menu.

KEY KeyLabel

Specifies the key or key combination used to activate the menu bar. For a list of available keys and key combinations and their key label names, see ON KEY LABEL.

Including the KEY clause is equivalent to issuing the following command:

ON KEY LABEL KeyLabel ACTIVATE MENU MenuName

Note   If a keyboard macro is already defined with the same key label, the keyboard macro takes precedence, and the menu bar cannot be activated with the specified key or key combination.

MARK cMarkCharacter

Specifies a mark character that appears to the left of the menu titles on the menu bar. MARK can be included to change the default mark character to a character specified with cMarkCharacter. If cMarkCharacter includes more than one character, only the first character is used as the mark character.

The default mark character is a check. The MARK clause is ignored and the default mark character is used if the menu bar is the Visual FoxPro system menu. Also, the MARK clause is ignored if FoxFont isn't the font for the main Visual FoxPro window or the user-defined window in which the menu bar is placed.

Note   Specifying a mark character doesn't mark the menu names on a menu bar. Use SET MARK OF to mark the menu titles on a menu bar with the character you specify.

Mark characters specified with DEFINE PAD take precedence over mark characters specified with the MARK clause in DEFINE MENU. SET MARK OF is used to toggle mark characters on or off, and can also be used to specify a mark character for an individual menu item or for all menu items.

MESSAGE cMessageText

Displays a message when the user selects a menu title. The message is placed in the graphical status bar. If the graphical status bar is turned off with SET STATUS BAR OFF, the message is centered on the last line of the main Visual FoxPro window.

NOMARGIN

Removes the spaces that are placed to the left and right of each menu name by default.

COLOR SCHEME nSchemeNumber

Specifies the colors for an individual menu bar.

COLOR ColorPairList

Specifies the colors for an individual menu bar. By default, the colors of menu items are determined by color scheme 2 of the current color set.

For more information on color schemes and color pairs, see the Colors Overview online topic.

Remarks

Use DEFINE MENU to create the menu bar for your application's menu system. Use DEFINE PAD to create each of the menu titles (pads) on the menu bar. Use ON PAD ... ACTIVATE to specify which menu is displayed under each menu title. Use DEFINE POPUP to create the menus under each menu title. Use ACTIVATE MENU to activate the entire menu system.

If you use the Menu Designer to create your menu, you may not have to use these commands at all. The Menu Designer automatically creates the commands for your menu. The Menu Designer uses the Visual FoxPro system menu, which you can then modify by adding your own menu items.

For more information on creating menus, see "Creating a Menu System" in Chapter 11, Designing Menus and Toolbars, in the Programmer's Guide.