Click here to Skip to main content
15,662,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I am working MFC Application, this application is compiled using VS2008.
To capture the key pressed
OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
method is used.

The strange thing happening is when i press the key "a" without caps lock its gives the nChar value as "65" which is suppose to be "97".

Even if the caps lock is "ON" the value i get is "65" when i press "A".

The thing is either the caps lock is on or off, i get the same value as if the caps lock is on. (this is the case with all the keys)

as the OnKeyUp() is as MFC method, I am not sure how to solve this issue.

Kindly help me and let me know if you require any more information.

Below is the code i am using, because of this what happens is, when i set a text using SetDlgItemText(), it is always going as Upper case letter or word.

void CMyProg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
CString SBCommand;
CString Temp;
char *s = NULL;
char strnChar[10];

/* Alphabets and Numerals passed to the command box */
if((nChar >= 65 && nChar <= 90) || (nChar >= 48 && nChar <= 57))
SBCommand += Temp;

SBCommand += (char*)nChar;

1 solution

Why don't you use OnChar[^]?
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900