home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / graphics / text.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-31  |  1.6 KB  |  57 lines

  1. /* TEXT.C illustrates text output functions including:
  2.  *    _gettextcolor   _getbkcolor   _gettextposition   _outtext
  3.  *    _settextcolor   _setbkcolor   _settextposition   _clearscreen
  4.  *
  5.  * See MODES.C for another use of _outtext and WINDOW.C for another
  6.  * use of _clearscreen.
  7.  */
  8.  
  9. #include <conio.h>
  10. #include <stdio.h>
  11. #include <graph.h>
  12.  
  13. char buffer [80];
  14.  
  15. main()
  16. {
  17.     short blink, fgd, oldfgd;
  18.     long bgd, oldbgd;
  19.     struct rccoord oldpos;
  20.  
  21.     /* Save original foreground, background, and text position. */
  22.     oldfgd = _gettextcolor();
  23.     oldbgd = _getbkcolor();
  24.     oldpos = _gettextposition();
  25.     _clearscreen( _GCLEARSCREEN );
  26.  
  27.     /* First time no blink, second time blinking. */
  28.     for( blink = 0; blink <= 16; blink += 16 )
  29.     {
  30.  
  31.         /* Loop through 8 background colors. */
  32.         for( bgd = 0; bgd < 8; bgd++ )
  33.         {
  34.             _setbkcolor( bgd );
  35.             _settextposition( (short)bgd + ((blink / 16) * 9) + 3, 1 );
  36.             _settextcolor( 7 );
  37.             sprintf(buffer, "Back: %d Fore:", bgd );
  38.             _outtext( buffer );
  39.  
  40.             /* Loop through 16 foreground colors. */
  41.             for( fgd = 0; fgd < 16; fgd++ )
  42.             {
  43.                 _settextcolor( fgd + blink );
  44.                 sprintf( buffer, " %2d ", fgd + blink );
  45.                 _outtext( buffer );
  46.             }
  47.         }
  48.     }
  49.     getch();
  50.  
  51.     /* Restore original foreground and background. */
  52.     _settextcolor( oldfgd );
  53.     _setbkcolor( oldbgd );
  54.     _clearscreen( _GCLEARSCREEN );
  55.     _settextposition( oldpos.row, oldpos.col );
  56. }
  57.