【发布时间】:2011-08-25 21:10:00
【问题描述】:
在下面的代码中,我应该如何在控制台底部创建一个彩色条? 以下代码使栏位于最顶部,但我不想在底部创建栏。我该怎么做?
void main(void)
{
HANDLE hOutput = (HANDLE)GetStdHandle( STD_OUTPUT_HANDLE );
// Set the text output position to (5,10)
COORD sPos;
sPos.X = 5;
sPos.Y = 10;
SetConsoleCursorPosition( hOutput, sPos );
// Set the color to bright green
SetConsoleTextAttribute( hOutput,
FOREGROUND_INTENSITY | FOREGROUND_GREEN );
// Write the text
DWORD nWritten;
WriteConsole( hOutput, "This is a test", 14, &nWritten, NULL );
CHAR_INFO buffer[SCREEN_HEIGHT][SCREEN_WIDTH];
COORD dwBufferSize = { SCREEN_WIDTH,SCREEN_HEIGHT };
COORD dwBufferCoord = { 0, 0 };
SMALL_RECT rcRegion = { 0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1 };
WriteConsoleOutput( hOutput, (CHAR_INFO *)buffer, dwBufferSize,
dwBufferCoord, &rcRegion );
}
【问题讨论】:
-
Windows 应用程序没有
void main()函数。
标签: c winapi console console-application