Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create shortcutmenu by code

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
I just started to create a new VCX for a new application.
I used some basics from the examples in 1001-things.
In the book an editboxclass is described which uses in the rightclick event a quickmenu. In the example the shortcutmenu seemed to be created in the normal (not coded) way.
As I like the availability to select just the VCX for another project it seems a better solution to me to create the shortcut menu by code in the rightclick of the editboxclass within the VCX.
But howto ?
-Bart
 
Bart,
Create a menu in usual way. Compile it and then just open and see file with your Menu name and MPR extension. That way you can create a dynamic menu.

Borislav Borissov
 

Bart,

Are you saying that you want to code the menu using DEFINE BAR, ON SELECTION BAR, and similar commands?

If so, your code will be almost identical to doing a normal menu. The main difference is that, instead of DEFINE PAD, you'll start with something like this:

Code:
DEFINE POPUP MyShortcut SHORTCUT RELATIVE FROM MROW(),MCOL()

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi,
Thanks for the advices. They do what expected but..
Code:
DEFINE POPUP shortcut SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF shortcut PROMPT "\<Expand"
DEFINE BAR 2 OF shortcut PROMPT "\<Shrink"
DEFINE BAR 3 OF shortcut PROMPT "Change \<Font"
ON SELECTION BAR 1 OF shortcut pnMenuChoice = 1
ON SELECTION BAR 2 OF shortcut pnMenuChoice = 2
ON SELECTION BAR 3 OF shortcut pnMenuChoice = 3

ACTIVATE POPUP shortcut
this is what is among others in the rightclick event
As this code will be executed everytime the rightclick event fires, is there no need to remove or destroy, or some like that, the created shortcutmenu?

-Bart
 

Bart,

No need to specifically destroy the popup. Assuming the whole thing is in a PRG file, just DO that file in the right-click.

But I don't see why you don't use the menu designer for this. I know it's not the slickets part of VFP, but it will generate pretty much the same code that you would otherwise write yourself.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi!
The reason why I don't want to have a 'loose' menu in the application is to be able to pick out the vcx and use it for another app without thinking which accompanying files to pick out out as well.
-Bart
 
Geoff,
Agreed,
But than still there might be several popup menus defined once I have several editboxes on the form.
-Bart
 
Geoff,
No, I just appreciate others 'voice' for sure. It often lead also to other solutions!.
Any way thanks for your help.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top