DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Change text colour in console (http://www.daniweb.com/forums/thread44367.html)

axiss Apr 28th, 2006 4:34 pm
Change text colour in console
 
Hi I was just wondering how you change the text colour of only some of the text in a console when you are using cout to display your text.

I tried using
system("Color XY");

obviously where X and Y are hex numbers and X sets the background color and Y the foreground (or text) colour, but this isn't very useful since the whole screen just changes the the last set of colours in the code for that particular console display instead of just the selected text changing colour.

iamthwee Apr 28th, 2006 4:55 pm
Re: Change text colour in console
 
I wouldn't bother. Pointless in my opinion. It's rather hackish.

Can be done in much better way.

Ancient Dragon Apr 28th, 2006 6:50 pm
Re: Change text colour in console
 
Quote:

Originally Posted by axiss
Hi I was just wondering how you change the text colour of only some of the text in a console when you are using cout to display your text.

it will all depend on the operating system. MS-Windows, use win32 api console functions. I don't know about *nix but probably use a curses library. You can download some free examples from here


All times are GMT -4. The time now is 4:23 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC