14.5. Other Input Events

As demonstrated in Listing 14.5, the programmer can view a console input stream at two different levels. The ReadFile function accesses the input queue at a high level, returning one key at a time. There is also low-level access to the queue, however, using the PeekConsoleInput, ReadConsole Input, and WriteConsoleInput functions. Three types of events appear in the buffer:

  • Keyboard events

  • Mouse events

  • Window re-size events

Listing 14.6 demonstrates how to access these low-level events.

Code Listing 14.6. Accessing low-level input from a console
 // events.cpp #include <windows.h> #include <iostream.h> void ErrorHandler(char *s, DWORD err) { cout << s << endl; cout << "Error number: " << err << endl; ExitProcess(err); ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.