Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible bug in keypress
Message
 
 
To
02/08/2007 15:06:16
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01245609
Message ID:
01245616
Views:
19
>I have created a textbox baseclass which I use whenever I want only uppercase text. The code in Keypress is/was as follows
>LPARAMETERS nKeyCode, nShiftAltCtrl
>if IsAlpha(Chr(nKeyCode)) && and nKeyCode=>0 && Remove the first && to see the bug
>  DoDefault(Asc(Upper(Chr(nKeyCode))))
>  NoDefault
>EndIf
>This code runs fine EXCEPT when any of the function keys are cleared, because default function keys set negative values for nKeyCode, and cause chr(nKeyCode) to generate an error. So I added a check for nKeyCode>0, which appeared to work fine for most keys, but not all. The following keys are simply "eaten" when I check for nKeyCode>0 by adding the "and nKeyCode=>0": D,E,F,G,T,U,V and W, plus a few international characters.
>
>I checked the ascii value for these characters:
>D 68 0x00000044
>E 69 0x00000045
>F 70 0x00000046
>G 71 0x00000047
>T 84 0x00000054
>U 85 0x00000055
>V 86 0x00000054
>W 87 0x00000056
>My observation is that the groups of "eaten" characters are exactly 4 bit apart, but I have no idea of why.
>
>In desperation I isolated the two conditions, and then it worked as expected:
>LPARAMETERS nKeyCode, nShiftAltCtrl
>if IsAlpha(Chr(nKeyCode))
>  If nKeyCode=>0
>    DoDefault(Asc(Upper(Chr(nKeyCode))))
>    NoDefault
>  EndIf
>EndIf
>
>Does anybody have a logical explanation for this strange behavior, which must be an obscure bug?

Search here, I believe I have this problem discussed.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform