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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 6 - Right-click "context menu"

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
141
GB
Hiya

I'm trying to find info on activating or enabling the right-click "context menu" for ease of access to copy, paste etc

By "context menu" I mean the menu that comes up on the right mouse button while editing a program in VFP etc or working in Word or Excel.

The trouble is I always ask the wrong questions when searching and so can never find the answers I seek!!

I have migrated thru mfoxplus (19 years ago), DOS FoxPro, FPW26 and now stopped with VFP6 - but even as far as my coding has come on, I still haven't been able to provide the same mouse / clipboard or drag and drop functionality that other Apps do by default.

Please can anyone point me in the right direction for this info - or let me know if I will have to (wo)man-handle this facility.

I don't know if its another wood/trees issue for me - but any pointers would be appreciated

Thank you

Karen
 
Hi Karen,

This is quite straightforward. There are two steps.

First, you need to create the menu. The easiest way to do that is to use the VFP Menu Designer.

When you launch the designer, choose "Shortcut" (rather than "Menu") when prompted to do so. In the designer proper, click the Insert Bar button. In the resulting dialogue, choose each of the required commands in turn (that is, Cut, Copy, ...), and click on Insert each time. (TIP: Choose these in the reverse order from how you want them to appear in the menu. You'll see why). Close the Insert Bar dialogue.

Next, generate the menu, which you do from the Menu menu (yes, it's really called that). Finally, save the menu and close the menu designer. You now have a menu file, which is a text file with the extension MPR.

The second step is to activate the menu in your application. To do so, write code in the right-click method of the controls to which the menu will apply. These will typically be textboxes and edit boxes. Ideally, you will have created subclasses of these controls, in which case you can simply place the code at the class level, but that is not essential.

The code simply says DO MENU MyMenu.MPR (the .MPR is important).

I think you'll find that'll do the trick.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike

Thanks for your response.
I'll certainly give it a go.

Karen
 
Just adding to Mike's usual great post. In the shortcut designer I click on options and disable some of the items like paste if the user does not have permission to edit the particular field the shortcut menu was called from.

Auguy
Northwest Ohio
 
You might also like to check VFPX and especially the OOP menu effort:
And I rather like to code a simple shortcut menu like this:

Code:
Deactivate Popup contextmenu
Release Popups contextmenu Extended

Define Popup contextmenu SHORTCUT Relative From Mrow(),Mcol()
Define Bar 1 Of contextmenu Prompt "<<menuitem>>" <<HOTKEY>>, "<<HOTKEY>>"
On Selection Bar 1 Of contextmenu <<command>>
...

Simply Do StrToFile(Sys(2013),"sysmenuitems.txt" to get a list of system menu items.

To to more complex things than a command, you can of course simply call a procedure, prg or method.

But even if you want a security question messagebox you can do it in one line:

Code:
On Selection Bar 1 Of contextmenu IIF(Messagebox("sure?",36,"application question")=6,<<command>>,_vfp.DoCmd("*"))

Bye, Olaf.
 
One more suggestion. Doug Hennig had an article in FoxTalk some years ago that provided a really nice structure for handling right-click menus. I'm using it in an app I'm working on now and it makes managing these menus really easy.

Unfortunately, I can't remember which issue it was right now.

Tamar
 
The OOP menu project on VFPX is a more recent version of my FoxTalk article source code.

Doug
 
Actually, that's not the article I meant. The one I'm thinking of was a framework of sorts for shortcut menus, involving some methods in the base form class.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top