#include <iostream>
#include "windows.h"
using namespace std;
int main()
{
cout << "原色testCOLOR(没有设置字体颜色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << "白色testCOLOR(红色绿色蓝色相加)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "红色testCOLOR(设置的颜色为红色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN)
;
cout << "绿色testCOLOR(设置的颜色为绿色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
cout << "蓝色testCOLOR(设置的颜色为蓝色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
FOREGROUND_GREEN);
cout << "黄色testCOLOR(红色和绿色相加色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |
FOREGROUND_BLUE);
cout << "粉色testCOLOR(红色和蓝色相加色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |
FOREGROUND_BLUE);
cout << "青色testCOLOR(绿色和蓝色相加色)" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
cout << endl;
system("pause");
return 0;
}
|