Archived

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

Acer722

Change text color in Win32 Console Program?

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.


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