How to Return to a Menu's Submenu After a Selection

Last reviewed: June 12, 1996
Article ID: Q137180
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a

SUMMARY

When a user makes a selection from a menu, the menu disappears and then the selection is executed. Some programmers want to have their users returned to the selected menu and submenu with the last choice highlighted. This article gives the steps you need to follow for every menu option you want to return to.

NOTE: If a menu is disabled at the time the ACTIVATE POPUP command is issued, it will not activate the last menu. This can occur when you create a Quick Menu and use the default menus supplied by FoxPro. FoxPro will automatically enable and disable menus depending on the current status and environment in FoxPro. For example, the Record menu is enabled only when a database file is open. Clicking an option on this menu runs a procedure that closes the database file in the current work area, the Record menu becomes disabled and the ACTIVATE POPUP command will not be able to redisplay the Record submenu.

MORE INFORMATION

Step-by-Step Procedure

  1. Create a quick menu.

  2. Insert a new menu option on the Edit menu, and set the Result to the Procedure option.

  3. In the procedure, enter these statements:

    PRIVATE lcLastPopup, lnLastBar

    lcLastPopup = POPUP()

       lnLastBar   = BAR()
    
       * place your statement(s) here that
       * will be executed for your menu option
    
       ACTIVATE POPUP &lcLastPopUp BAR lnLastBar
    
    

  4. Save the menu, and generate the menu code.

  5. When you run the menu, the selected option will run, but when it is completed, the menu and submenu will reappear, and the last option selected will be highlighted.

NOTE: The above procedure calls the menu procedure recursively. If the procedure is performed more than 32 times, a "Do nesting too deep" error message may be displayed.


Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a 2.50b 2.50c
2.60 2.60a Sticky
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.