KB007: Providing Cut/Copy/Paste in Your Application

Topic: Visual FoxPro
Last updated: May 10, 2001

Users expect your application to work like other Windows programs. Providing Cut, Copy, and Paste functions is important. This article shows you how to do it.

You can learn the secrets by creating a Quick Menu. To do this, type CREATE MENU in the Command Window, then select Menu from the Dialog box. The Menu Designer will be displayed. From the VFP menu, select Menu|Quick Menu.

Now, in the Menu Designer, look at the Options for the Edit menu. You'll notice that the Pad Name is _msm_Edit. That's the first key. Give your Edit menu the same Pad Name.

Next, drill down into the Edit menu and notice that Cut, Copy, and Paste and all have a Result of Bar #, with their respective bar numbers of _med_cut, _med_copy, and _med_paste. That's the next key. Set your Edit menu to have the same bar numbers.

Finally, drill down into the options and set your short-cut keys to Ctrl+X, Ctrl+C, and Ctrl+V.

A shortcut (right-click) menu is just as easy. Each menu option will be the same Bar # that you specified in the Edit menu.

It's now easy to provide this functionality in a toolbar. In the Click Method of the toolbar buttons, keyboard the appropriate command. For example, for Copy, KEYBOARD "{CTRL+C}" will do the trick. Note that the Edit menu must be defined for this to work

 
                                   
                                    Copyright © 2001-2005, Craig Berntson.  All Rights Reserved.