Char Output Color

I have been trying to output characters in the console in colors other than the sixteen default colors that

SetConsoleTextAttribute( hstdout, 0xa );

will let you do, i.e.

1
2
3
4
5
6
7
8
0 = Black       8 = Gray
1 = Blue        9 = Light Blue
2 = Green       A = Light Green
3 = Aqua        B = Light Aqua
4 = Red         C = Light Red
5 = Purple      D = Light Purple
6 = Yellow      E = Light Yellow
7 = White       F = Bright White


I want to specify the color with RGB values.

I tried using this,

1
2
3
COLORREF B = RGB(100,0,0);

SetConsoleTextAttribute( hstdout, B );	


but it did the text w/ red foreground and yellow background, not just the regular black background!

Thanks so much!

Numeri

Last edited on
Bump.
You are limited to 16 distinct colors at any one time, but you can actually modify the colors used. See SetConsoleScreenBufferInfoEx()
http://www.google.com/search?btnI=1&q=msdn+SetConsoleScreenBufferInfoEx

(Check out the ColorTable in the CONSOLE_SCREEN_BUFFER_INFOEX structure.)

Good luck!
Topic archived. No new replies allowed.