Archived

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

virus3355

change text color in console app?

Recommended Posts

acidkobra    122
sure but what are u using to make the window and draw the text? windows gdi or directX. Or something else?

The only thing that defines man from animal is our knowledge of computer programming.

Share this post


Link to post
Share on other sites
pawn69    122
HANDLE consoleWindow = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(consoleWindow, &csbiInfo);
SetConsoleTextAttribute(consoleWindow, FOREGROUND_RED | FOREGROUND_GREEN);
printf("bla bla bla\n");
SetConsoleTextAttribute(consoleWindow, csbiInfo.wAttributes);

Share this post


Link to post
Share on other sites
l3mon    128
How about just writing

system("color 03");

for example??

You can check the colour definitions when simply typing 'color /help' in console.
Hope that helps

[edited by - l3mon on January 28, 2003 4:17:47 AM]

Share this post


Link to post
Share on other sites
virus3355    122
How about just changing the color of a certain part of the text?

Like not the whole program.

Example

i just want to change the color of:


cout << "BLUE" << endl;


not the entire program.

EDIT:
im guessing you cant have several different lines in different colors... just ONE foreground and ONE background?

I'm so sad
[edited by - virus3355 on January 28, 2003 6:32:03 PM]

[edited by - virus3355 on January 28, 2003 6:32:45 PM]

[edited by - virus3355 on January 28, 2003 7:07:53 PM]

[edited by - virus3355 on January 29, 2003 9:38:08 AM]

Share this post


Link to post
Share on other sites
Gonzzor    122
Hi..

Don''t know if the escape codes are supported my Windows consoles... In Linux, you can use escape codes to change the color of the text...

Haven''t got any time to try it out now, but you might want to check out escape codes...

Share this post


Link to post
Share on other sites