Annotation of mstools/samples/console/fillchar.c, revision 1.1.1.1

1.1       root        1: #include <windows.h>
                      2: #include "console.h"
                      3: 
                      4: /*******************************************************************
                      5: * FUNCTION: demoFillChar(HANDLE hConOut)                           *
                      6: *                                                                  *
                      7: * PURPOSE: demonstrate FillConsoleOutputCharacter. Fill the entire *
                      8: *          console with the character that the user hits           *
                      9: *                                                                  *
                     10: * INPUT: the output console to fill with characters                *
                     11: ********************************************************************/
                     12: 
                     13: void demoFillChar(HANDLE hConOut)
                     14: {
                     15:   HANDLE hStdIn;
                     16:   INPUT_RECORD inputBuf;
                     17:   CHAR c; /* ascii character read from the console */
                     18:   CONSOLE_SCREEN_BUFFER_INFO csbi;
                     19:   COORD coordScreen = {0, 1}; /* location to start the attribute fill */
                     20:   DWORD cCharsWritten;
                     21:   BOOL bSuccess; 
                     22:   DWORD cInputEvents;
                     23: 
                     24:   setConTitle(__FILE__);
                     25:   myPuts(hConOut, "Let's fill the console buffer with a given character by\n"
                     26:                   "using the FillConsoleOutputCharacter API. Hit a key to \n"
                     27:                   "fill the buffer with (hit ESC to return):");
                     28:   hStdIn = GetStdHandle(STD_INPUT_HANDLE);
                     29:   PERR((int) hStdIn != -1, "GetStdHandle");
                     30:   for(;;)
                     31:     {
                     32:     do
                     33:       {
                     34:       /* get input events until you get a key-down event */
                     35:       bSuccess = ReadConsoleInput(hStdIn, &inputBuf, 1, &cInputEvents);
                     36:       PERR(bSuccess, "ReadConsoleInput");
                     37:       } while (inputBuf.EventType != KEY_EVENT ||
                     38:             !inputBuf.Event.KeyEvent.bKeyDown);
                     39:     c = (char) inputBuf.Event.KeyEvent.uChar.AsciiChar;
                     40:     if (inputBuf.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
                     41:       break;
                     42:     /* we need to get the console buffer size */
                     43:     bSuccess = GetConsoleScreenBufferInfo(hConOut, &csbi);
                     44:     PERR(bSuccess, "GetConsoleScreenBufferInfo");
                     45:     bSuccess = FillConsoleOutputCharacter(hConOut, /* screen buffer handle */
                     46:         c, /* character to write */
                     47:         (csbi.dwSize.X * csbi.dwSize.Y) - csbi.dwSize.X, /* number of chars */
                     48:         coordScreen, /* x and y coordinates of first cell */
                     49:         &cCharsWritten); /* receives number of cells written to */
                     50:     PERR(bSuccess, "FillConsoleOutputCharacter");
                     51:   }
                     52:   return;
                     53: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.