Salut,
2 petites macros très simples pour gérer la couleur de la console win
(couleurs différentes au "mot" ou à la ligne)
#include <Windows.h>
#include <string>
#include
// 2 couleurs de test
#define color1 (WORD)(0x0003 | 0x0000)//bleu-vert sur noir
#define color2 (WORD)(0x0007 | 0x0008 | 0x0040) //blanc sur rouge
#define COLOR(h, c) SetConsoleTextAttribute(h, c);
#define TEXTCOLOR(h,c1,c2,s) COLOR(h,c1); std::cout<<s; COLOR(h,c2);
int main(int argc, char** argv)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
WORD wCouleurDefaut = csbiInfo.wAttributes;
std::cout << "Couleur defaut..." << std::endl;
COLOR(hStdout, color1);
std::cout << "Change couleur ligne complete..." << std::endl;
COLOR(hStdout, wCouleurDefaut);
std::cout << "Change couleur sur un seul ";
TEXTCOLOR(hStdout, color2, wCouleurDefaut, "mot");
std::cout << "..."<< std::endl;
std::cout << std::endl << "[ENTER] pour quitter :\r\n";
std::cin.getline((char*)std::string("").c_str(), 4, '\n');
return 0;
}
bye...