trouble trapping two keys presses

Started by Martin Francom, January 21, 2010, 11:17:37 PM

Previous topic - Next topic

Martin Francom

I need to prevent a user from entering in any TEXTBOX on the FORM either of these characters:    ^   ~

I know I can trap them in the EN_CHANGE for each Textbox but was hoping I could trap them in the FF_PUMPHOOK Function.   There doesn't appear to be a %VK_  for those characters probably because the require the shift key to type them.

Any suggestions how I can trap them and not allow them to type into any Textbox on the form. ???

Roger Garstang

#1
Haven't tested, but in inc file:

%VK_OEM_3        = &HC0   ' "`~" for US

The other would probably need to check for 6 key with Shift.  May be easier to wait and get the Char instead of Keypresses using WM_CHAR.

If you use FF's built in WM_CHAR for the textbox the chCharCode will be the ascii of the char. Something like below will block the 'a' key:

If chCharCode = 97 Then Function = 1

You will need to handle when they paste too or block it.

Textbox custom:
If wMsg = %WM_PASTE Then Function = 1

Martin Francom

Thanks Roger.   I will play with those suggestions tonight. And if I can make them work.

Gary Stout

It looks like the shift key is &H10 and the tilde is &H7E and ^ is &H5E. These are all for keypress. The keyUp code changes for the 2 keys (&HC0 and &H36 respectively).

Maybe this will get you started.

Gary