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

1.1.1.3 ! root        1: 
        !             2: /******************************************************************************\
        !             3: *       This is a part of the Microsoft Source Code Samples. 
        !             4: *       Copyright (C) 1993 Microsoft Corporation.
        !             5: *       All rights reserved. 
        !             6: *       This source code is only intended as a supplement to 
        !             7: *       Microsoft Development Tools and/or WinHelp documentation.
        !             8: *       See these sources for detailed information regarding the 
        !             9: *       Microsoft samples programs.
        !            10: \******************************************************************************/
        !            11: 
1.1       root       12: #include <windows.h>
                     13: #include "console.h"
                     14: 
                     15: /*******************************************************************
                     16: * FUNCTION: demoFillChar(HANDLE hConOut)                           *
                     17: *                                                                  *
                     18: * PURPOSE: demonstrate FillConsoleOutputCharacter. Fill the entire *
                     19: *          console with the character that the user hits           *
                     20: *                                                                  *
                     21: * INPUT: the output console to fill with characters                *
                     22: ********************************************************************/
                     23: 
                     24: void demoFillChar(HANDLE hConOut)
                     25: {
                     26:   HANDLE hStdIn;
                     27:   INPUT_RECORD inputBuf;
                     28:   CHAR c; /* ascii character read from the console */
                     29:   CONSOLE_SCREEN_BUFFER_INFO csbi;
                     30:   COORD coordScreen = {0, 1}; /* location to start the attribute fill */
                     31:   DWORD cCharsWritten;
                     32:   BOOL bSuccess; 
                     33:   DWORD cInputEvents;
                     34: 
                     35:   setConTitle(__FILE__);
                     36:   myPuts(hConOut, "Let's fill the console buffer with a given character by\n"
                     37:                   "using the FillConsoleOutputCharacter API. Hit a key to \n"
                     38:                   "fill the buffer with (hit ESC to return):");
                     39:   hStdIn = GetStdHandle(STD_INPUT_HANDLE);
1.1.1.2   root       40:   PERR(hStdIn != INVALID_HANDLE_VALUE, "GetStdHandle");
1.1       root       41:   for(;;)
                     42:     {
                     43:     do
                     44:       {
                     45:       /* get input events until you get a key-down event */
                     46:       bSuccess = ReadConsoleInput(hStdIn, &inputBuf, 1, &cInputEvents);
                     47:       PERR(bSuccess, "ReadConsoleInput");
                     48:       } while (inputBuf.EventType != KEY_EVENT ||
                     49:             !inputBuf.Event.KeyEvent.bKeyDown);
                     50:     c = (char) inputBuf.Event.KeyEvent.uChar.AsciiChar;
                     51:     if (inputBuf.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
                     52:       break;
                     53:     /* we need to get the console buffer size */
                     54:     bSuccess = GetConsoleScreenBufferInfo(hConOut, &csbi);
                     55:     PERR(bSuccess, "GetConsoleScreenBufferInfo");
                     56:     bSuccess = FillConsoleOutputCharacter(hConOut, /* screen buffer handle */
                     57:         c, /* character to write */
                     58:         (csbi.dwSize.X * csbi.dwSize.Y) - csbi.dwSize.X, /* number of chars */
                     59:         coordScreen, /* x and y coordinates of first cell */
                     60:         &cCharsWritten); /* receives number of cells written to */
                     61:     PERR(bSuccess, "FillConsoleOutputCharacter");
                     62:   }
                     63:   return;
                     64: }

unix.superglobalmegacorp.com

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