Click to See Complete Forum and Search --> : Please HELP onchar() problem
April 30th, 1999, 07:16 AM
Hai ,
I am using onchar() to catch what key is pressed , i need to set one variable if an alphabet is pressed .
In onchar() , the value we got is character code , we can do checking with VK_A ..... VK_Z .. so 27 checking is needed , is there any ohter way like VK_A has HEX value 41 ...VK_Z has 5A so what i did is if( nChar>41 && nChar< 5A) then setting my variable but it is giving error like 'bad suffic format'
i know i am comparing UINT and hex but i don't know how to correct this
please help me.
bye
Masaaki
April 30th, 1999, 11:54 AM
Hi.
If you want to catch A~Z, try this format.
if((nChar >= 65) && (nChar <= 90))
{
Your job here.
}
HTH.
-Masaaki Onishi-
Rail Jon Rogut
April 30th, 1999, 01:43 PM
If you want to use the Hex value... Just place 0x in front of the value:
if (nChar > 0x40 && nChar < 0x5B)
But why not just use:
if (nChar >= VK_A && nChar <= VK_Z)
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/
thanx a lot , i want to know when this onchar() will be called , i debugged , the code is not reachable , if i press 'a' from keyboard , this calls onchar() please tell me when onchar () will be called and what way this is useful
bye
thanx a lot
ammu
Rail Jon Rogut
May 3rd, 1999, 02:10 PM
Hi
(Please go to the top of the page and edit your profile, so we can have a name for you instead of Anonymous)
It all depends on where you're trying to get the keyboard input... What are you doing? Is this in a view, in a dialog with an edit control?
If you're trying to look for certain keystrokes in an edit control, then one would subclass the CEdit control (derive your own class from CEdit) and catch OnChar() there.
I have an example on my web site which shows how to derive a class from CEdit.
Go to http://home.earthlink.net/~railro/mfc_link.html and check out Example 5.
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.