Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Change text color in Win32 Console Program?

This topic is 6298 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 found my text based rpg that I made a year ago in a Dos program (Win32 Console Program) I was playing around with it and one thing that would make it more eye pleasing is color. How do I add color to the text? I have no clue because I now do Windows programming, MFC, DirectX and OpenGL. And if there is code try and keep it C++, and havent worked with dos in a while. Thanks in advance.

Share this post

Link to post
Share on other sites
There is no C++ standard for console colour.

Some compiler come with conio (console input/output) which has some handy console stuff like, colour and cursor position.

So if you want to use colour in your C++ console program, it won''t be portable as it is now.

DJGPP has the conio header I''m talking about.
MSVC Has it, but not the functions.


Share this post

Link to post
Share on other sites
I think the fastest way is to create two arrays:
-- characters[2000] and
-- attributes[2000].

Then you can use WriteConsoleOutputCharacter and WriteConsoleOutputAttribute.

You get the handle for these functions (parameter 1) by HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!