Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Substituting characters while typing in Edit box
Message
From
06/02/1998 10:06:56
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Substituting characters while typing in Edit box
Miscellaneous
Thread ID:
00076872
Message ID:
00076872
Views:
60
I am designing a terminal emulator and need to map certain keys to special characters during user input.

The best solution I have come up with so far is rather cludgy, and am looking for a more elegant approach:

I am using the KeyPress Event of the edit box to trap for the key I need to convert and insert the character I want its place:

IF nKeyCode = 61 .AND. nShiftAltCtrl = 0
THIS.Value = THIS.Value + CHR(42)
nValueLength = LEN(THIS.Value)
lKeyChange = .T.
ENDIF

However, this by itself results in the Edit box value being the original value, plus CHR(42), plus the trapped key (in this case '[')

In order to get rid of the trapped key, I added this code to the InteractiveChange Event of the edit box:

IF lKeyChange
THIS.Value = LEFT(THIS.Value,nValueLength)
ENDIF

While this works, you will sometimes see the '[' character appear briefly in the edit box, then disappear, which obviously doesn't look very good.

Any ideas ?
Next
Reply
Map
View

Click here to load this message in the networking platform