Jump to content
  • Advertisement
Sign in to follow this  
vinb

textcolor() for a non-Borland user?

This topic is 5463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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()?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!