The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a
SUMMARY
Disable.exe is a sample that shows how to enable and disable menus, menu
pads and menu bars in a Top-Level form in Visual FoxPro 5.x.
MORE INFORMATION
The following file is available for download from the Microsoft Software
Library:
~ Disable.exe (size: 25263 bytes)
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591
TITLE : How to Obtain Microsoft Support Files from Online Services
To use the files included, follow these steps:
- Download the Disable.exe file and place it in a new folder.
- Double-click Disable.exe to extract the files.
- Once the files are extracted, start Visual FoxPro 5.x.
- In Visual FoxPro, set the default directory to the location of the files
through the Tools, Options dialog box, File Locations tab or with the
SET DEFAULT TO command.
- Start the program by issuing DO Disable.prg in the Visual FoxPro Command
window or by choosing Do from the Program menu and choosing Disable.prg.
- Click the buttons to disable and enable menu items as desired.
- Quit and examine the Disable.mnx, Disable.scx and Disable.prg files as
desired.
Symptoms
Menu pads and the menu bars on those menu pads do not disable properly and
then do not re-enable when changing the SKIP FOR setting when the menu is
placed in an SDI form. In the case of menu pad bars, when the SKIP FOR
setting is changed to true, the bar will not disable (turn gray) until the
second time it is chosen. However, the command or procedure assigned to
that bar will not run. In the case of the menu pad, it also does not
disable until the second time it is chosen. However, even though the menu
will drop down, the options on it will not function.
Changing the SKIP FOR setting means that a logical memory variable is setup
in the Prompt Options dialog box for a menu prompt in the Skip For: box.
Normally changing that memory variable to True or False will enable or
disable the prompt if the menu is not in a Top-Level(SDI) form.
Resolution
The best resolution to this is to issue the full SET SKIP OF command to
enable or disable the menu components. To get the example in the Steps To
Reproduce Behavior to work properly, add the following code in the places
indicated.
In the Toggle Disable Menu button click method, make this the second line
of code:
SET SKIP OF PAD colors OF (Thisform.Name) lMenu
In the Toggle Disable Menu Bar button click method, make this the second
line of code:
SET SKIP OF BAR 1 OF colors lRed
See the attached sample files for a better example of disabling and re-
enabling menus in a Top-Level form.
Status
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. We are researching this problem
and will post new information here in the Microsoft Knowledge Base as it
becomes available.
Additional Information
When designing a menu in the Menu Designer, a logical memory variable can
be placed in the SKIP FOR expression in the Prompt Options dialog box. The
logical values .T. or .F. can also be used for this expression but they
cannot be changed at runtime and this problem still occurs.
Steps to Reproduce Behavior
The following steps to reproduce the behavior assume a working knowledge of
the Menu Designer and Form Designer in Visual FoxPro:
- Create a new program file and save it as NoDisabl.prg. Place the
following code in the program file, and then save and close it:
lMenu=.F.
lRed=.F.
DO FORM NoDisabl
READ EVENTS
- Create a new menu in the Menu Designer called NoDisabl.
- At the prompt for the first menu pad, type "Colors." Make the result a
Submenu. Click the Options button and place "lMenu" in the Skip For
text box (in the Prompt Options dialog box). Type in "colors" in the
Pad Name box. Click OK to exit the Prompt Options dialog box.
NOTE: The Pad Name is not necessary to reproduce the problem. The pad
name will be used later to illustrate a workaround to the problem.
- Choose the Create button to create the Submenu.
- To create two menu bar prompts, type "Red" and "Blue." Make the result
of each a command. For the commands, enter:
WAIT WINDOW "Red"
-and-
WAIT WINDOW "Blue"
- Click the Options button for the Red bar. In the Prompt Options dialog
box, place "lRed" in the Skip For box. Click OK to exit the Prompt
Options dialog box.
- From the View menu, select General Options. Check the Top-Level Form
check box in the General Options dialog box. Click OK.
- Select the Generate command from the Menu, and then save and generate
the menu. Name the menu files "NoDisabl.mnx" and "NoDisabl.mpr."
- Create a new form named NoDisabl.
- In the Init method of the form, place the following code:
DO NoDisabl.mpr WITH THIS, .T.
- In the Destroy method of the form, place the following code:
RELEASE MENU (THIS.Name) EXTENDED
CLEAR EVENTS
- Place three CommandButtons on the form. Change the caption properties
on the buttons to Quit, Toggle Disable Menu, and Toggle Disable Menu
Bar.
- In the Click method of the Quit button, place the following code:
Thisform.release
- In the Click method of the Toggle Disable Menu, place the following
code:
lMenu=!lMenu
IF lMenu
WAIT WINDOW "lMenu is True, the pad should be disabled"
ELSE
WAIT WINDOW "lMenu is False, the pad should be reenabled"
ENDIF
Thisform.refresh
- In the Click method of the Toggle Disable Menu Bar, place the following
code:
lRed=!lRed
IF lRed
WAIT WINDOW "lRed is True, menu bar Red should be disabled"
ELSE
WAIT WINDOW "lRed is False, menu bar Red should be reenabled"
ENDIF
Thisform.refresh
- Set the ShowWindow property of the form to be 2 - As Top-Level Form.
- Save the form as NoDisabl.scx and close it.
- Issue the following command in the Visual FoxPro Command window:
DO NoDisabl.prg
- Pull down the menu (use the mouse for this and the following steps) and
ensure the Color options work.
- Click the Toggle Disable Menu Bar button, note the WAIT WINDOW that
appears. Pull down the menu and choose Red. Note that it is not
disabled (gray) but the WAIT WINDOW does not appear. Pull down the menu
again. The Red option should now be disabled (gray). Click the Toggle
Disable Menu Bar button again and pull down the menu. Note that Red
is still disabled.
- Click on the Toggle Disable Menu button. Note the WAIT WINDOW and pull
down the menu. Notice that it is not disabled but the Blue option
doesn't bring up its WAIT WINDOW. Click on the menu pad again. It
should immediately disable, if it is not already disabled. Click the
Toggle Disable Menu button again. Note that the menu pad does not
re-enable.
- The menu pad should now be re-enabled but the mouse cannot get it to
work. Press the ALT key and click the menu pad. It should now be
re-enabled and the Blue option should work.
- To see the menu work as expected outside the form, undo the following
or re-create the example without the following:
- Step #7 - uncheck the Top-Level form and be sure to regenerate
the menu.
- Steps #10, 11 - remark out these lines of code.
- Step #16 - set the ShowWindow property of the form to 0 - In Screen.
- Add the following line of code to the NoDisabl.prg file just before
the DO FORM NoDisabl line:
DO NoDisabl.mpr
- In the NoDisabl.prg file, place SET SYSMENU TO DEFAULT after the
CLEAR EVENTS command.
When you run the NoDisabl program, the menu should work as expected.
The Pad will not show as enabled or disabled until you click on it
once or press the ALT key.
Keywords : FxprgGeneral FxtoolFormdes FxtoolMBuilder vfoxwin
Version : WINDOWS:5.0,5.0a
Platform : WINDOWS
Issue type : kbfile
Solution Type : kbsample