The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5x, 2.6x
- Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6x
- Microsoft FoxPro for Macintosh, version 2.5x, 2.6a
SUMMARY
This article shows by example how to create a screen and give it an active
menu while also keeping the main system menu active. For example, the Trace
window has its own menu and is active while the main FoxPro system menu is
active.
MORE INFORMATION
For information about how to attach a menu to a Visual FoxPro 3.0 form,
please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q135517
TITLE : How to Attach a Menu to a Form
FoxPro 2.x Instructions
You could create a menu to be included with a screen by hand coding the
menu. But it is easier to use FoxPro's menu generator to generate menu
code. Then you can identify and copy the appropriate sections of generated
code (.MPR), and paste these sections into the screen code (.SCX).
Step-by-Step Example
- Create a screen file, and give the screen a name in the screen layout.
- Create a menu to go with the screen by using the menu builder. Then
generate it by using the menu generator.
- Create a #SECTION2 in the setup code of the screen. On the last line of
the Setup snippet of your screen, type in the following:
#SECTION2
- Copy the "Menu Definitions" section of the generated menu file (the .MPR
file) to the line below the #SECTION2 section created in the previous
step. But do not copy any of the menu procedure code; this code will be
placed in the cleanup code of the screen.
- Copy the menu procedures labeled on the selection bar to the screen
cleanup and procedures section of the screen. From this point on all
reference in this article to menu code will refer to the menu code
copied to the screen (.SCX) file.
- In the menu code, replace the first line (SET SYSMENU TO) with "define
menu <menu name> in window <screen name>" where menu name is any name
you want and screen name is the name you gave the screen in the screen
layout dialog box.
For example, if the menu generator generated the following first two
lines of code:
SET SYSMENU TO
SET SYSMENU AUTOMATIC
Replace the above lines with the following;
SET SYSMENU AUTOMATIC
DEFINE MENU mymenu IN WINDOW test
- In the menu code, replace all occurrences of _MSYSMENU with your menu
name. For example, one line of the menu code might look like this:
DEFINE PAD _qt00iyosr OF _MSYSMENU PROMPT "file" COLOR SCHEME 3
Change the _MSYSMENU to your menu name (for example, mymenu):
DEFINE PAD _qt00iyosr OF mymenu PROMPT "file" COLOR SCHEME 3
- Change the following lines:
ON SELECTION BAR 1 OF file ;
DO _qt00iyovc ;
IN LOCFILE(...
To this:
ON SELECTION BAR 1 OF file ;
DO _qt00iyovc
- Add the following line to the ON WINDOW ACTIVATE clause of the screen
code:
ACTIVATE MENU mymenu NOWAIT
- Generate the screen code, and execute the .SPR file.
NOTE: The menu created in the above example isn't a true system menu, so
the menu does not look or behave exactly like a system menu. For example,
if you select a menu pad you must execute "DEACTIVATE POPUP padname" to
close up the pad. Clicking with the mouse off the menu pad will not
deactivate the menu.
|