Thread: Question about ASCII codes

  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,218
    That is because they use windows messages and stuff like that (which is strictly Win32 dependant).
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

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, 06:30 PM
  2. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  3. File i/o and ASCII question
    By muzihc in forum C Programming
    Replies: 13
    Last Post: 11-04-2008, 11:46 PM
  4. Question regarding queue codes
    By Velocity in forum C++ Programming
    Replies: 10
    Last Post: 11-02-2008, 04: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