textcolor() for a non-Borland user?

Started by
1 comment, last by vinb 19 years, 6 months ago
I wrote a console version of MasterMind (anybody remember that game?) as a class project and I thought it would be nice to have the text in different colors. Is there a microsoft version of textcolor()?
Advertisement
Well if you mean for a console program. You can do this:
HANDLE stdCon = GetStdHandle(STD_OUTPUT_HANDLE);
Then using this handle you can change the color and
reposition text etc...
Here is the msdn document of SetConsoleAttribute:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setconsoletextattribute.asp

So then you can do something like this:
SetConsoleTextAttribute(stdCon,FOREGROUND_RED);

Make sure to include windows.h with this as well.

-TOmcAT
-Keith
This works. Thanks. I assume I can find the other color constants in windows.h? Oh, I get it. Never mind. I'll make my own using the hex color values.

This topic is closed to new replies.

Advertisement