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

How to activate option copy and paste in a form

Status
Not open for further replies.

VictorFRodriguez

Programmer
Jan 20, 2001
51
DO
I have a form with an Edit Box and I need to use the right click button to make copy and paste.
How can I enabled this option? Does anyone can show me a code?
Thanks
Victor F. Rodriguez
 
Hi Victor,
It depends on the version you are using.

If you are using VFP 6 follow this

Add following code to KeyPress event into your form -

IF nShiftAltCtrl=2
DO CASE
CASE nKeyCode=3
SYS(1500, '_med_copy', '_medit')
CASE nKeyCode=22
SYS(1500, '_med_paste', '_medit')
NODEFAULT
CASE nKeyCode=24
SYS(1500, '_med_cut', '_medit')
NODEFAULT
ENDCASE
ENDIF

However VFP3 does not have SYS(1500) or _medit functions.

Use this code -
IF nShiftAltCtrl=2
DO CASE
CASE nKeyCode=3
STOR This.seltext TO _CLIPTEXT
CASE nKeyCode=22
STOR _CLIPTEXT TO mtxt
STOR mtxt TO This.Seltext
NODEFAULT
CASE nKeyCode=24
STOR This.seltext TO _CLIPTEXT
STOR "" TO This.seltext
NODEFAULT
ENDC
ENDI

Further if you use this on form level it will apply to all objects. If you don't want to provide this facility to combo boxes where data are fetched from master tables, add above code in the KeyPress event of only required objects-textboxes, editboxes, etc.

Good luck!!

PURU
 
Hi Victor,
It depends on the version you are using.

If you are using VFP 6 follow this

Add following code to KeyPress event into your form -

IF nShiftAltCtrl=2
DO CASE
CASE nKeyCode=3
SYS(1500, '_med_copy', '_medit')
CASE nKeyCode=22
SYS(1500, '_med_paste', '_medit')
NODEFAULT
CASE nKeyCode=24
SYS(1500, '_med_cut', '_medit')
NODEFAULT
ENDCASE
ENDIF

However VFP3 does not have SYS(1500) or _medit functions.

Use this code -
IF nShiftAltCtrl=2
DO CASE
CASE nKeyCode=3
STOR This.seltext TO _CLIPTEXT
CASE nKeyCode=22
STOR _CLIPTEXT TO mtxt
STOR mtxt TO This.Seltext
NODEFAULT
CASE nKeyCode=24
STOR This.seltext TO _CLIPTEXT
STOR "" TO This.seltext
NODEFAULT
ENDC
ENDI

Further if you use this on form level it will apply to all objects. If you don't want to provide this facility to combo boxes where data are fetched from master tables, add above code in the KeyPress event of only required objects-textboxes, editboxes, etc.

Good luck!!

PURU

********
Addition -

This way you can user can use Ctrl+c, Ctrl+v, Ctrl+x.

It is better to provide toolbar rather than RightClick.

PURU
 
Victor,

As an alternative to Puru's suggestion, you could create a context menu (the kind that pops up when you right-click) containing Cut, Copy and Paste commands.

Follow these steps:

- Open the menu designer and select 'Shortcut' from the initial screen.

- For each prompt in the menu, press 'Insert Bar', and choose, in turn, Cut, Copy, Paste.

- Save and generate the menu. (Let's suppose you save it as Context.mnx and put the generated code in Context.Mpr).

- In the RightClick event of your edit box, put this code:
DO Context.Mpr

That's it. The nice thing about this approach is that the user will also have the choice of using Ctrl-C, etc, without any extra effort on your part.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top