Question about ASCII codes

This is a discussion on Question about ASCII codes within the C++ Programming forums, part of the General Programming Boards category; I am making a program that displays the elements of a struct to the screen. I want to be able ...

  1. #1
    Master of Puppets rwmarsh's Avatar
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    96

    Question about ASCII codes

    I am making a program that displays the elements of a struct to the screen. I want to be able to use the tab key to move to each area on the screen where the elements are displayed so that I can change the variables, and then hit F8 to update the file. I have this bit of code that checks the ascii code of a key press.
    Code:
    static int Get_Code()                  // Get ASCII code from a key press
    {
        int ch = getch();
        if ( ch == 0 || ch == 224 ) ch = 256 + getch();
        return ch;
    }
    This works fine except that I want to be able to hit TAB to move forward and SHIFT TAB to move backwards. This code produces the same ascii code for both (9). How can I use SHIFT TAB?
    Using DEV-C++ Under Windows XP
    +------------------------------+

    "No! Do, or Do Not. There is no Try..."

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    some keys don't have shift+key combinations. You can use Ctrl+Tab which is 148.

  3. #3
    Master of Puppets rwmarsh's Avatar
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    96
    I figured there must be a way to use shift tab since, for example, you can use it in internet explorer to move backwards through different fields on the screen.
    Using DEV-C++ Under Windows XP
    +------------------------------+

    "No! Do, or Do Not. There is no Try..."

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    IE does not use getch() -- win32 api functions will probably have that info in the structure or bitmapped word that is returned to the application program when a key is pressed..

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    1,198
    That is because they use windows messages and stuff like that (which is strictly Win32 dependant).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ascii string question
    By transgalactic2 in forum C Programming
    Replies: 6
    Last Post: 01-06-2009, 05:30 PM
  2. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  3. File i/o and ASCII question
    By muzihc in forum C Programming
    Replies: 13
    Last Post: 11-04-2008, 10:46 PM
  4. Question regarding queue codes
    By Velocity in forum C++ Programming
    Replies: 10
    Last Post: 11-02-2008, 03:01 PM
  5. ASCII character with ASCII value 0 and 32
    By hitesh_best in forum C Programming
    Replies: 4
    Last Post: 07-24-2007, 09:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21