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!

Keypress event in RTF Textbox

Status
Not open for further replies.

kamweng

Programmer
Jan 20, 2012
36
MY
My keypress worked fine in a textbox but I could not make it work in a RTF textbox:

*** ActiveX Control Event ***
LPARAMETERS keyascii

IF keyascii = -8 && F9
MESSAGEBOX(0,0,0) && For example
ENDIF

RETURN

Is there anything else that I should be aware of?

Thank you.
 
The Keypress for an ActiveX control works differently from that of a native control. In particular, it does not work with the same key values. In the ActiveX control, you can only trap the "printable" ASCII characters, such as A - Z a - z, 0 - 9, etc. - not function keys such as F9.

If you need to trap function keys, use KeyDown instead:
Code:
*** ActiveX Control Event ***
LPARAMETERS keycode, shift

IF keycode = 120
	MESSAGEBOX("F9 was pressed")
ENDIF


Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Keypress return the ASCII code. -8 is not an ASCII code.

Use keydown / keyup instead

Code:
*** ActiveX Control Event ***
LPARAMETERS keycode, shift
IF keycode = 120 && F9
	MESSAGEBOX(0,0,"Ole!") && For example
ENDIF

Here is a list with keyboard key codes versus ASCII codes



Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Thank you for the replies.

I was wondering why RTF Textbox used LPARAMETERS keyascii whereas the normal Textbox used LPARAMETERS nKeyCode, nShiftAltCtrl.

Once again, thank you.
 
Code:
*** ActiveX Control Event ***
This hints for non native events always. ActiveX is always a non VFP thing and has its own rules.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top