Jump to content
  • Advertisement

Archived

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

Acer722

Change text color in Win32 Console Program?

This topic is 6198 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
Advertisement
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.


www.omf.com

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);


Darkening

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!