Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to coordinate a form with a shortcut menu
Message
From
17/08/2000 18:31:26
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Menus & Menu designer
Title:
How to coordinate a form with a shortcut menu
Miscellaneous
Thread ID:
00406448
Message ID:
00406448
Views:
50
Suppose you'd like to be able to run a method of the calling form from within a command or procedure of a shortcut menu. You'd like a way to do this generically so you don't have to put any references to the runtime name of the form in the menu code.

One solution is to pass THISFORM as a parameter to the shortcut menu. You can accept a parameter in a menu by placing a PARAMETERS statement in the menu's Setup method. Use "PARAMETERS" instead of "LPARAMETERS" so that the parameter you pass will be visible to commands and procedures in the menu. Then, simply use the parameter, which is an object reference to the form, to call the desired method from within the menu.

Here's an example. Create a form called myForm. In its RightClick method put
DO myShortcutMenu.mpr WITH THISFORM
Add a custom method to myForm named SayHello, and in there use a wait window or a messagebox to say 'Hello'.

Now, create a shortcut menu named myShortcutMenu. In its Setup method put
PARAMETERS oCallingForm
Add a menu bar with whatever prompt you like, and in its command write
oCallingForm.SayHello()
That's all there is to it. If you're doing this outside of a project, don't forget to generate the menu code (myShortcutMenu.mpr) before running the form.

The parameter could be any object reference, of course. For example you could pass a reference to a business object instead of to the form itself, if that's where the desired method was located.
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Next
Reply
Map
View

Click here to load this message in the networking platform