Colour in C++ !?!
Okay, well I've been doing C++ for a while now (only the basics) and I'm wondering how to get colour in a console program. I know you can use:
markupSystem("color 0c");
For example but that will change the whole screen colour to Black and Red.
I'm wondering how to just change the colour of like one word at a time, and have another word in a different colour. I don't know if this can be done, infact I doubt it myself but if it can please let me know how. :)
heres the long way: add windows.h to your includes, add a variable "HANDLE handle", make it valid to your console: handle=CreateFile("CONOUT$",GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
then the function: SetConsoleTextAttribute(handle,(WORD)(backgroundcolor) | foregroundcolor));
both of which are ints, theyre the same as the int argument for color apart from instead of a its 10 etc. etc.
i know thats long but hope it helps lol
mr noob wrote: heres the long way: add windows.h to your includes, add a variable "HANDLE handle", make it valid to your console: handle=CreateFile("CONOUT$",GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
then the function: SetConsoleTextAttribute(handle,(WORD)(backgroundcolor) | foregroundcolor));
both of which are ints, theyre the same as the int argument for color apart from instead of a its 10 etc. etc.
i know thats long but hope it helps lol
Umm thanks I think but I don't understand it lol.