Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

PUSH MENU, POP MENU, PUSH POPUP, POP POPUP

These commands let you save and restore a defined menu or popup, so you can replace it with another, then return to it.

Usage

PUSH MENU MenuName
POP MENU MenuName [ TO MASTER ]
PUSH POPUP PopupName
POP POPUP PopupName

The PUSH and POP in these commands are the traditional operations of a stack—a last-in, first-out data structure that resembles our desks. You put things into a stack (or push them) one at a time. When you remove something (or pop it) from the stack, you get the last one you added first. (Calling and returning from procedures uses a stack, too—when you call a procedure, the one you’re in gets pushed onto a stack. Each subsequent call adds another procedure to the stack. When you hit a return, the top item on the stack—the routine that called the one you’re in—is popped.)

FoxPro gives us access to several stacks, including the two here, for menu and popup definitions. We rarely use the popup stack, but the menu stack is really handy. You can PUSH MENU _MSYSMENU to save the current system menu, then run a menu program (MPR) that makes some changes—maybe adds another pad or removes a few bars. When you’re done with the operation, just POP MENU _MSYSMENU and you have the original menu back.

You can use the menu stack to make your menu work the way FoxPro’s does. On the way into a particular form, you can add a menu pad specific to that form. When you leave the form, you can get rid of that pad. In an event-driven app, you’ll probably want to do all this menu handling in the form’s (or formset’s) Activate and Deactivate events.

Example

* In a form's Activate event
PUSH MENU _MSYSMENU
DO MyForm.MPR

* In the form's Deactivate
POP MENU _MSYSMENU

See Also

Define Menu, Define Popup, Menus