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:27:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/02/1998 10:06:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00076872
Message ID:
00076882
Views:
28
>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 ?
Trapped key is with the keycode 61 ? I'm asking this because I've something different from "[" for it, 91 for "[". If it's the case and you just want to absorb it add a nodefault in the keypress.
IF nKeyCode = 61 .AND. nShiftAltCtrl = 0
   nodefault
   THIS.Value = THIS.Value + CHR(42)
ENDIF
So you wouldn't need the interactivechange also.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform