From: sos AT prospect DOT com DOT ru (Sergey Okhapkin) Subject: RE: "GetNumberOfConsoleInputEvents" never 0? 1 Mar 1997 05:43:01 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <01BC2637.88D8D620.cygnus.gnu-win32@sos> Original-To: "'Peter Dalgaard BSA'"

Original-Cc: "gnu-win32 AT cygnus DOT com" , "'Geoffrey Noer'" Encoding: 79 TEXT Original-Sender: owner-gnu-win32 AT cygnus DOT com Peter Dalgaard BSA wrote: > Does this have anything to do with the character composition bug? > (I.e. dead keys not working - tilde/backquote gone on my keyboard) You mean entering "national" characters with ascii code > 128? This is a bug of Windows 95. There are two methods to read keyboard in Win32 API - ReadFile() (ReadConsole()) and ReadConsoleInput(). The first (two) calls allows entering such characters, but "filters" non-ascii keys (arrows, F-keys, etc.). ReadConsoleInput() allows to read functional keys but keyboard layout switcher doesn't work on Win95 with this call! There is no problems with NT. I used the following work-around in my programs on Win95: /* * int ReadKey (void) - reads console input (including function * keys and national characters). * Return value: * ASCII character (OEM codepage) in low byte * Virtual Keycode of function key in high byte if low byte == 0. * BUGS: * This function does not filter keyboard layout switching * hot keys. * * Original design by Boris Usievich. * Custom implementation by Sergey Okhapkin */ #include int ReadKey() { INPUT_RECORD irBuffer; DWORD n; int ch; HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleMode(hIn, ENABLE_PROCESSED_INPUT); do { PeekConsoleInput(hIn, &irBuffer, 1, &n); if (n==0) { Sleep(100); continue; } if (irBuffer.EventType == KEY_EVENT && irBuffer.Event.KeyEvent.bKeyDown) { if (irBuffer.Event.KeyEvent.uChar.AsciiChar != '\0') { ReadConsole(hIn, &ch, 1, &n, NULL); return ch & 0xff; } else { ReadConsoleInput(hIn, &irBuffer, 1, &n); return irBuffer.Event.KeyEvent.wVirtualKeyCode << 8; }; } else ReadConsoleInput(hIn, &irBuffer, 1, &n); } while (TRUE); } #include void main() { int ch; for(;;) { if ((ch = ReadKey()) & 0xff) printf("%c", ch); else printf("VK_%d", (ch >> 8) & 0xff); } } -- Sergey Okhapkin Moscow, Russia Looking for a job - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".