unsigned short SetConsoleColor( unsigned short ForeColor, unsigned short BackGroundColor)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&csbiInfo))
{
printf("GetConsoleScreenBufferInfo error!n");
return 0;
}
if (!SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),ForeColor|BackGroundColor))
{
printf("SetConsoleTextAttribute error!n");
return 0;
}
return csbiInfo.wAttributes;
}
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_RED, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_INTENSITY | FOREGROUND_GREEN, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_RED | FOREGROUND_GREEN, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_RED | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_GREEN | FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_RED, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_BLUE, 0);
printf("1 = %25.15en", x);
SetColorWhite();
SetConsoleColor(FOREGROUND_GREEN, 0);
printf("1 = %25.15en", x);
SetColorWhite();
对应的颜色如下:
https://blog.sciencenet.cn/blog-268489-607822.html
上一篇:
Visua Studio 2008 编译 cminpack下一篇:
OpenGL球体移动动画,基于VC++ MFC,收藏