textcolor() for a non-Borland user?
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()?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement