The Stupid GetKey() Function

Fixing it the easy way
During class, we have discovered that the code I previously posted in SCRNIO.C's GetKey function did not correctly handle the Shift-Tab key. My recommendation to you is that you change the definition of the Shift-Tab key (move to previous field) to be a Ctrl-Tab key. This means that you will need to add the definition for CTRLTAB to your myio.h (put it right under the one for SHIFTTAB). You will also need to alter your EditData function so that it uses the Ctrl-Tab key, and not Shift-Tab, to move to the previous field. The hex value for the CTRLTAB key is 0x9400.

The Hard way
The above changes should take you no more than 20 minutes. If however, your interested in making your project work as originally intended, so that Shift-Tab moves you to the previous field (like it does in all windows programs, then you must do the following:

1. Add #include <wincon.h>, in myio.h, under the #include<windows.h>

2. In scrnio.c, add the following under static HANDLE hStdOut; :
static HANDLE hStdIn;

3. Add the following, at the end of the Init() function in scrnio.c:

if( !hStdIn )
    perror( "Error initializing console");

4. Change your GetKey function in scrnio.c, so that it now looks like this:

int GetKey( void )
    int i;
#ifndef WIN32
    if( (i=getch()) == 0 || (i==0xE0) )
        return( i=getch()*0x100 );
#ifdef WIN32
/* 12/1/98 - This complex crap is needed, to make GetKey work like it used to in DOS*/
    int JustModifier;
    DWORD Read;
    do {
        i=ReadConsoleInput( hStdIn, &ib, 1, &Read );
        JustModifier = (ib.Event.KeyEvent.wVirtualKeyCode>=16) && (ib.Event.KeyEvent.wVirtualKeyCode<=18);
        if( !ib.Event.KeyEvent.bKeyDown )
        Read = 0;
    } while( Read==0 || ib.EventType!=KEY_EVENT || JustModifier /*|| ib.Event.KeyEvent.uChar.UnicodeChar==0*/);
    if( ib.Event.KeyEvent.uChar.UnicodeChar==0 )
        i = ib.Event.KeyEvent.wVirtualScanCode * 0x100;
        i = ib.Event.KeyEvent.uChar.AsciiChar;
    if( i==TAB && ib.Event.KeyEvent.dwControlKeyState == 16 )
        i = SHFTTAB;

Please note: I'm on a new computer, and once again do not have the Borland compiler installed, so I am unable to test the above code in anything but Visual C++ 6.0 at this time. If you are not having problems with the Shift-Tab key, or if you are happy with changing to the Contrl-Tab key, then do you do not need to make these changes.