From: John den Haan on 18 Feb 2007 16:56 Jerry Coffin schreef: > In article <af976$45d8abd1$d4bb52d9$3185(a)news.chello.nl>, > nospam(a)nospam.com says... >> Hello! >> >> I was wondering if it is possible to change the color in the console >> output? And if so, what color gradients are available (how many colors)? > > Yes. For example, SetConsoleTextAttribute can set colors. If memory > serves, you get a total of 16 colors each for foreground and background. > For each primary color (red, green and blue) you can specify off, on a > half intensity, or on at full intensity. > SetConsoleTextAttribute worked, thanks. The palette is very limited, but I guess that's just something I'll have to work with. -- Cheers, John den Haan joDhn[dot]haEan[at]chLello[dot]nl Remove capital 'DEL' from above addy to obtain e-mail address
From: James Brown on 18 Feb 2007 17:56
"Alf P. Steinbach" <alfps(a)start.no> wrote in message news:53rpqdF1ti370U1(a)mid.individual.net... >* John den Haan: >> >> I was wondering if it is possible to change the color in the console >> output? > > Yes - check out the console functions, and perhaps also the color command, > > C:\Documents and Settings\Alf> color /? > Sets the default console foreground and background colors. > > COLOR [attr] > > attr Specifies color attribute of console output > > Color attributes are specified by TWO hex digits -- the first > corresponds to the background; the second the foreground. Each digit > can be any of the following values: > > 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 > > If no argument is given, this command restores the color to what it was > when CMD.EXE started. This value either comes from the current console > window, the /T command line switch or from the DefaultColor registry > value. > > The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute > the COLOR command with a foreground and background color that are the > same. > > Example: "COLOR fc" produces light red on bright white > > C:\Documents and Settings\Alf> _ > > >> And if so, what color gradients are available (how many colors)? > > There is a palette of 16 colors, modelling the restrictions of early PC > video adapters (console windows were originally DOS program compatibility > boxes). > > I don't recall if you can change the palette. > > -- > A: Because it messes up the order in which people normally read text. > Q: Why is it such a bad thing? > A: Top-posting. > Q: What is the most annoying thing on usenet and in e-mail? console colour-palette may be modified on NT-based systems using the code at: www.catch22.net/sources There is also a new API under Vista which does the same thing (SetConsoleScreenBufferEx) -- James Brown Microsoft MVP - Windows SDK www.catch22.net Free Win32 Tutorials and Sourcecode |