JavaScript Editor js editor     Web development 



Main Page

Creates a menu title (pad) on a user-defined menu bar or the Visual FoxPro system menu bar.

DEFINE PAD MenuTitle1 OF MenuBarName PROMPT cMenuTitleText
   [AT nRow, nColumn] [BEFORE MenuName2 | AFTER MenuName3] 
   [NEGOTIATE cContainerPosition [, cObjectPosition]]
   [FONT cFontName [, nFontSize [, nFontCharSet]]] [STYLE cFontStyle] 
   [KEY KeyLabel [, cKeyText]] [MARK cMarkCharacter] 
   [SKIP [FOR lExpression]] [MESSAGE cMessageText] 
   [COLOR SCHEME nSchemeNumber | COLOR ColorPairList]

Parameters

MenuTitle1


Specifies the menu title to create. The menu title allows you to reference the menu title in other commands and functions.
OF MenuBarName


Specifies the name of the menu bar in which the menu title is placed.
PROMPT cMenuTitleText


Specifies the text that appears in the menu title. You can create an access key for a menu title by placing a backslash and a less-than sign (\<) before the character you would like to be the access key. In the following example, the user can press the I key to choose Invoices from the Receive menu and press the Q key to choose Inquiry from the same menu:
В Copy Code
DEFINE MENU mnuReceive
DEFINE PAD padInvoice OF mnureceive PROMPT "\<Invoices"
DEFINE PAD padInquire OF mnureceive PROMPT "In\<quiry"
ACTIVATE MENU mnuReceive
AT nRow, nColumn


Specifies where the menu title appears on the menu bar. nRow, nColumn are the coordinates of the left side of the menu title in the main Visual FoxPro window or in a user-defined window. If you omit the AT clause, the left side of the first menu title is placed in row 0 of the main Visual FoxPro window or user-defined window. The next menu title is placed to the right of the first name on row 0, and so on.
Note:
You cannot include AT to specify a location for menu titles in menu bars created with the BAR clause in DEFINE MENU.

BEFORE MenuName2


Places the menu title on the menu bar to the left of the menu title specified with MenuName2. The order the menu titles are accessed from the keyboard corresponds to the location of the menu titles in the menu bar.
AFTER MenuName3


Places the menu title on the menu bar to the right of the menu title specified with MenuName3. The order the menu titles are accessed from the keyboard corresponds to the location of the menu titles in the menu bar. You must first create the menu title you specify in a BEFORE or AFTER clause. If you don't create the menu title first, the placement of the menu title on the menu bar is determined by the order in which it is created or by a location specified with the AT clause. For menu bars created without BAR, BEFORE or AFTER determines the order the menu titles are accessed from the keyboard. The location of a menu title is determined by the location specified with the AT clause. Run the following two examples and note the differences in menu title placement and access order when menu titles are defined with and without the AT clause:
В Copy Code
*** Program Example 1 without ATs ***
DEFINE MENU mnuBefAft
DEFINE PAD padOne OF mnuBefAft PROMPT '1111'
DEFINE PAD padTwo OF mnuBefAft PROMPT '2222'
DEFINE PAD padThree OF mnuBefAft PROMPT '3333'
DEFINE PAD padFour  OF mnuBefAft PROMPT '4444' BEFORE padTwo
ACTIVATE MENU mnuBefAft

*** Program Example 2 with ATs ***
DEFINE MENU mnuBefAft
DEFINE PAD padOne OF mnuBefAft PROMPT '1111' AT 1,5
DEFINE PAD padTwo OF mnuBefAft PROMPT '2222' AT 1,15
DEFINE PAD padThree OF mnuBefAft PROMPT '3333' AT 1,25
DEFINE PAD padFour  OF mnuBefAft PROMPT '4444' BEFORE padTwo AT 1,35
WAIT WINDOW 'Press ESC to erase menu' NOWAIT
ACTIVATE MENU mnuBefAft
NEGOTIATE cContainerPosition[, cObjectPosition]


cContainerPosition specifies the location of the menu title in the Visual FoxPro menu bar when OLE visual editing occurs for an ActiveX control contained in a Visual FoxPro form. 'The settings for cContainerPosition are:

Setting Description

NONE

The menu title is not displayed.

LEFT

The menu title is placed to the left of the File Group.

MIDDLE

The menu title is placed to the left of the Container Group, after the Edit menu.

RIGHT

The menu title is placed to the left of the Window Group.

The settings for cObjectPosition are:

Setting Description

NONE

The menu title is not displayed.

LEFT

The menu title is placed to the right of the File Group.

MIDDLE

The menu title is placed to the right of the Container Group, after the Edit menu.

RIGHT

The menu title is placed on the Help menu.

If you omit the NEGOTIATE clause, the menu title is removed from the menu bar when OLE visual editing occurs; NONE is the default for both cContainerPosition and cObjectPosition.
FONT cFontName[, nFontSize [, nFontCharSet]]


Specifies a font for the menu title. cFontName specifies the name of the font, and nFontSize specifies the point size. You can specify a language script with nFontCharSet. See the GETFONT( ) Function for a list of available language script values. For example, the following command creates a menu title in 12-point Courier font:
В Copy Code
DEFINE PAD padPageAccts OF mnuReceive 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 font style for the menu title. 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:
В Copy Code
DEFINE PAD padPageAccts OF mnuReceive STYLE 'BI'
The STYLE 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.
KEY KeyLabel[, cKeyText]


Specifies an access key or key combination for a menu title. For a list of available keys and key combinations and their key label names, see ON KEY LABEL Command.
Note:
If a keyboard macro is already defined with the same key label, the keyboard macro takes precedence, and the menu title cannot be chosen with the specified key or key combination.

The key label is placed to the right of menu titles in menu bars created without the BAR clause. The key label isn't displayed in menu bars created with the BAR clause or for menu titles in the Visual FoxPro system menu bar. Include cKeyText to replace the key label with your own text. You can use any character in the cKeyText parameter; for example, you can use the text "^B" to indicate a key label of CTRL+B. For example, including KEY CTRL+B places the text CTRL+B on the menu to the right of the menu item name, but specifying KEY CTRL+B, "^B" places the text ^+B on the menu. You can suppress the display of a key label by specifying an empty string for cKeyText.
MARK cMarkCharacter


Specifies a mark character that appears to the left of the menu title. 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 containing the menu title 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 containing the menu title is placed. 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 marks on or off and can also be used to specify a mark character for an individual menu title or for all menu titles.
Note:
Specifying a mark character doesn't mark the menu title. Use SET MARK OF to mark a menu title with the character you specify.

SKIP [FOR lExpression]


Specifies a condition whereby if lExpression evaluates to true (.T.), the menu title is disabled, preventing the user form choosing it. If lExpression evaluates to false (.F.), the menu title is enabled. You can also disable a menu item by placing a backslash (\) before the text of the menu title text. For example:
В Copy Code
DEFINE PAD padPageAccts OF mnuReceive PROMPT '\Age Accounts'
The menu title padPageAccts is displayed dimmed, indicating that it cannot be chosen. A disabled menu title can be displayed but can't be selected. However, a message specified with the MESSAGE clause is displayed.
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.
COLOR SCHEME nSchemeNumber


Specifies the colors for an individual menu title, overriding the default colors or the colors specified with DEFINE MENU.
COLOR ColorPairList


Specifies the colors for an individual menu title, overriding the default colors or the colors specified with DEFINE MENU. By default, the colors of menu titles in menu bars are determined by color scheme 2 of the current color set.

Remarks

You must create each menu title placed on the menu bar with its own DEFINE PAD command. A menu bar must be defined with DEFINE MENU before you can place menu titles on it, and you must include the menu bar name in DEFINE PAD.

If you use the Menu and Shortcut Designers 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 Menu System Creation.

Example

The following example uses DEFINE PAD to place menu titles in the Visual FoxPro system menu bar. The current system menu bar is first saved to memory with SET SYSMENU SAVE, and then all system menu titles are removed with SET SYSMENU TO.

Several system menu titles are created with DEFINE PAD. When a menu title is chosen, the CHOICE procedure is executed. CHOICE displays the name of the chosen menu title and the name of the menu bar, and toggles the menu titles' mark character on and off. If the Exit menu title is chosen, the original Visual FoxPro system menu is restored.

В Copy Code
*** Name this program DEFINPAD.PRG ***
CLEAR
SET TALK OFF
SET SYSMENU SAVE
SET SYSMENU TO
PUBLIC markpad
markpad = .T.
DEFINE PAD syspad  OF _MSYSMENU PROMPT '\<System'  COLOR SCHEME 3 ;
   KEY ALT+S, ''
DEFINE PAD editpad OF _MSYSMENU PROMPT '\<Edit'  COLOR SCHEME 3 ;
   KEY ALT+E, ''
DEFINE PAD recordpad OF _MSYSMENU PROMPT '\<Record'  COLOR SCHEME 3 KEY ALT+R, ''
DEFINE PAD windowpad OF _MSYSMENU PROMPT '\<Window'  COLOR SCHEME 3 ;
   KEY ALT+W, ''
DEFINE PAD reportpad OF _MSYSMENU PROMPT 'Re\<ports' COLOR SCHEME 3 ;
   KEY ALT+P, ''
DEFINE PAD exitpad OF _MSYSMENU PROMPT 'E\<xit'  COLOR SCHEME 3 ;
   KEY ALT+X, ''
ON SELECTION MENU _MSYSMENU ;
   DO choice IN definpad WITH PAD( ), MENU( )
PROCEDURE choice
PARAMETER mpad, mmenu
WAIT WINDOW 'You chose ' + mpad + ;
   ' from menu ' + mmenu NOWAIT
SET MARK OF PAD (mpad) OF _MSYSMENU TO ;
   ! MRKPAD('_MSYSMENU', mpad)
markpad = ! markpad
IF mpad = 'EXITPAD'
   SET SYSMENU TO DEFAULT
ENDIF

See Also



JavaScript Editor js editor     Web development 
R7