鱼C论坛

 找回密码
 立即注册
查看: 3073|回复: 16

一个C语言的问题,高手进

[复制链接]
发表于 2013-7-18 23:21:31 | 显示全部楼层

帮你把代码贴出来:
  1. #include <windows.h>
  2. #include <stdio.h>

  3. int main( void )
  4. {
  5.     HANDLE hStdout;
  6.     CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
  7.     SMALL_RECT srctScrollRect, srctClipRect;
  8.     CHAR_INFO chiFill;
  9.     COORD coordDest;
  10.     int i;

  11.     printf("\nPrinting 20 lines for reference. ");
  12.     printf("Notice that line 6 is discarded during scrolling.\n");
  13.     for(i=0; i<=20; i++)
  14.         printf("%d\n", i);

  15.     hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

  16.     if (hStdout == INVALID_HANDLE_VALUE)
  17.     {
  18.         printf("GetStdHandle failed with %d\n", GetLastError());
  19.         return 1;
  20.     }

  21.     // Get the screen buffer size.

  22.     if (!GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
  23.     {
  24.         printf("GetConsoleScreenBufferInfo failed %d\n", GetLastError());
  25.         return 1;
  26.     }

  27.     // The scrolling rectangle is the bottom 15 rows of the
  28.     // screen buffer.

  29.     srctScrollRect.Top = csbiInfo.dwSize.Y - 16;
  30.     srctScrollRect.Bottom = csbiInfo.dwSize.Y - 1;
  31.     srctScrollRect.Left = 0;
  32.     srctScrollRect.Right = csbiInfo.dwSize.X - 1;

  33.     // The destination for the scroll rectangle is one row up.

  34.     coordDest.X = 0;
  35.     coordDest.Y = csbiInfo.dwSize.Y - 17;

  36.     // The clipping rectangle is the same as the scrolling rectangle.
  37.     // The destination row is left unchanged.

  38.     srctClipRect = srctScrollRect;

  39.     // Fill the bottom row with green blanks.

  40.     chiFill.Attributes = BACKGROUND_GREEN | FOREGROUND_RED;
  41.     chiFill.Char.AsciiChar = (char)' ';

  42.     // Scroll up one line.

  43.     if(!ScrollConsoleScreenBuffer(  
  44.         hStdout,         // screen buffer handle
  45.         &srctScrollRect, // scrolling rectangle
  46.         &srctClipRect,   // clipping rectangle
  47.         coordDest,       // top left destination cell
  48.         &chiFill))       // fill character and color
  49.     {
  50.         printf("ScrollConsoleScreenBuffer failed %d\n", GetLastError());
  51.         return 1;
  52.     }
  53. return 0;
  54. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-9 03:08

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表