CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Guest

    Please HELP onchar() problem

    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





  2. #2
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: Please HELP onchar() problem

    Hi.

    If you want to catch A~Z, try this format.

    if((nChar >= 65) && (nChar <= 90))
    {
    Your job here.
    }

    HTH.
    -Masaaki Onishi-


  3. #3
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Please HELP onchar() problem

    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
    [email protected]
    http://home.earthlink.net/~railro/

  4. #4
    Guest

    Re: Please HELP onchar() problem

    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


  5. #5
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Please HELP onchar() problem

    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
    [email protected]
    http://home.earthlink.net/~railro/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured