14.6. Other Capabilities

Several other functions in the console API make it easy to implement advanced capabilities in your consoles. For example, consoles support the concept of an active buffer, and allow you to change the active buffer at any time. Listing 14.8 demonstrates the process.

Code Listing 14.8. Switching between two buffers
 // 2buff.cpp #include <windows.h> #include <iostream.h> #include <string.h> void ErrorHandler(char *s, DWORD err) { cout << s << endl; cout << "Error number: " << err << endl; ExitProcess(err); } void ShowBuffers(HANDLE consoleStdin, HANDLE consoleStdout, HANDLE newBuffer) { char buffer[1000]; DWORD numRead, numWrite; BOOL flag=TRUE; int x; for (x=0; x<10; x++) { WriteFile(consoleStdout, "Black\n", 6, &numWrite, ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.