[RESOLVED] can anyone tell me all colors const for SetConsoleTextAttribute() function?
i have these nice function for change the textcolor\backcolor:
Code:
void SetColorAndBackground(int ForgC, int BackC){
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
return;
}
but can anyone tell me the colors const and and how can i blink?
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Well, I have to repeat: why don't you want to read MSDN? :confused:
SetConsoleTextAttribute function
character attributes
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
VictorN
sorry.. don't be mad with me. the msdn is limited in very ways:(
i have now the const that i can use them:
Code:
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHTGRAY 7
#define DARKGRAY 8
#define LIGHTBLUE 9
#define LIGHTGREEN 10
#define LIGHTCYAN 11
#define LIGHTRED 12
#define LIGHTMAGENTA 13
#define YELLOW 14
#define WHITE 15
void SetColorAndBackground(int ForgC, int BackC=0)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
i can't blink, but i think that i can do it, after i complete 1 little class.
(i have tested all colors and works)
let me ask you something: can you see all these colors in msdn?(that links you give me)
sorry but i don't like, not all there, how they explain and don't tell me all:(
or i need study how they tells us the things:(
(i will share the blink thing... the SetConsoleTextAttribute() can't do the blink, but i can do it;) )
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Well, whz reinvent the wheel?
From MSDN article Character Attributes:
Quote:
The following attributes are defined in the
Wincon.h header file.
Attribute FOREGROUND_BLUE
Text color contains blue.
FOREGROUND_GREEN
Text color contains green.
FOREGROUND_RED
FOREGROUND_INTENSITY
Text color is intensified.
BACKGROUND_BLUE
Background color contains blue.
BACKGROUND_GREEN
Background color contains green.
BACKGROUND_RED
Background color contains red.
BACKGROUND_INTENSITY
Background color is intensified.
An application can combine the foreground and background constants to achieve different colors. For example, the following combination results in bright cyan text on a blue background.
Code:
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_BLUE
And just FYI (from wincon.h):
Code:
#define FOREGROUND_BLUE 0x0001 // text color contains blue.
#define FOREGROUND_GREEN 0x0002 // text color contains green.
#define FOREGROUND_RED 0x0004 // text color contains red.
#define FOREGROUND_INTENSITY 0x0008 // text color is intensified.
#define BACKGROUND_BLUE 0x0010 // background color contains blue.
#define BACKGROUND_GREEN 0x0020 // background color contains green.
#define BACKGROUND_RED 0x0040 // background color contains red.
#define BACKGROUND_INTENSITY 0x0080 // background color is intensified.
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
VictorN
Well, whz reinvent the wheel?
From MSDN article
Character Attributes:
And just FYI (from wincon.h):
Code:
#define FOREGROUND_BLUE 0x0001 // text color contains blue.
#define FOREGROUND_GREEN 0x0002 // text color contains green.
#define FOREGROUND_RED 0x0004 // text color contains red.
#define FOREGROUND_INTENSITY 0x0008 // text color is intensified.
#define BACKGROUND_BLUE 0x0010 // background color contains blue.
#define BACKGROUND_GREEN 0x0020 // background color contains green.
#define BACKGROUND_RED 0x0040 // background color contains red.
#define BACKGROUND_INTENSITY 0x0080 // background color is intensified.
can you explain to me the COMMON_LVB_REVERSE_VIDEO atribute?
how can i combine the 'RGB' values?(imagine the yellow, how can i do it?)
(they don't show a sample:()
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
Cambalinho
can you explain to me the COMMON_LVB_REVERSE_VIDEO atribute?
MSDN already did explain it! It is just to
Quote:
Reverse foreground and background attribute.
In other words foreground attribute will be now applied to the foreground and v.v.
Quote:
Originally Posted by
Cambalinho
how can i combine the 'RGB' values?
Again. See MSDN
Quote:
An application can combine the foreground and background constants to achieve different colors. For example, the following combination results in bright cyan text on a blue background.
Code:
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_BLUE
Quote:
Originally Posted by
Cambalinho
imagine the yellow, how can i do it?
Very simple! For the foreground color it is
Code:
FOREGROUND_BLUE | FOREGROUND_GREEN
for background
Code:
BACKGROUND_BLUE | BACKGROUND_GREEN
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
VictorN
MSDN already did explain it! It is just toIn other words foreground attribute will be now applied to the foreground and v.v.
Again. See MSDN[/CODE]
Very simple! For the foreground color it is
Code:
FOREGROUND_BLUE | FOREGROUND_GREEN
for background
Code:
BACKGROUND_BLUE | BACKGROUND_GREEN
sorry. but i don't understand what means these:
"Reverse foreground and background attribute."
(i'm portguese)
is like the blink?
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
Cambalinho
sorry. but i don't understand what means these:
"Reverse foreground and background attribute."
(i'm portguese)
Did you try to use Englesh-Portguese dictionary? Or the Google-traslater?
Quote:
Atributo primeiro plano eo fundo reverter
Quote:
Originally Posted by
Cambalinho
is like the blink?
No.
Re: can anyone tell me all colors const for SetConsoleTextAttribute() function?
Quote:
Originally Posted by
VictorN
Did you try to use Englesh-Portguese dictionary? Or the Google-traslater?
No.
sorry something.. and thanks for all.. realy thanks
Re: [RESOLVED] can anyone tell me all colors const for SetConsoleTextAttribute() func
This may be of help
Code:
//Define extra colours
#define FOREGROUND_WHITE (FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_YELLOW (FOREGROUND_RED | FOREGROUND_GREEN)
#define FOREGROUND_CYAN (FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_MAGENTA (FOREGROUND_RED | FOREGROUND_BLUE)
#define FOREGROUND_BLACK 0
#define FOREGROUND_INTENSE_RED (FOREGROUND_RED | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_GREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_BLUE (FOREGROUND_BLUE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_WHITE (FOREGROUND_WHITE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_YELLOW (FOREGROUND_YELLOW | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_CYAN (FOREGROUND_CYAN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_MAGENTA (FOREGROUND_MAGENTA | FOREGROUND_INTENSITY)
#define BACKGROUND_WHITE (BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN)
#define BACKGROUND_YELLOW (BACKGROUND_RED | BACKGROUND_GREEN)
#define BACKGROUND_CYAN (BACKGROUND_BLUE | BACKGROUND_GREEN)
#define BACKGROUND_MAGENTA (BACKGROUND_RED | BACKGROUND_BLUE)
#define BACKGROUND_BLACK 0
#define BACKGROUND_INTENSE_RED (BACKGROUND_RED | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_GREEN (BACKGROUND_GREEN | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_BLUE (BACKGROUND_BLUE | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_WHITE (BACKGROUND_WHITE | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_YELLOW (BACKGROUND_YELLOW | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_CYAN (BACKGROUND_CYAN | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_MAGENTA (BACKGROUND_MAGENTA | BACKGROUND_INTENSITY)
There is no default mechanism to blink a character on screen. if you want this, it can be done by first reversing (exchanging) foreground and background attributes (COMMON_LVB_REVERSE_VIDEO) then setting a timer for the required blink period then reversing foreground and background attributes when timer triggers.
Re: [RESOLVED] can anyone tell me all colors const for SetConsoleTextAttribute() func
Quote:
Originally Posted by
2kaud
This may be of help
Code:
//Define extra colours
#define FOREGROUND_WHITE (FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_YELLOW (FOREGROUND_RED | FOREGROUND_GREEN)
#define FOREGROUND_CYAN (FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_MAGENTA (FOREGROUND_RED | FOREGROUND_BLUE)
#define FOREGROUND_BLACK 0
#define FOREGROUND_INTENSE_RED (FOREGROUND_RED | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_GREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_BLUE (FOREGROUND_BLUE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_WHITE (FOREGROUND_WHITE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_YELLOW (FOREGROUND_YELLOW | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_CYAN (FOREGROUND_CYAN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_MAGENTA (FOREGROUND_MAGENTA | FOREGROUND_INTENSITY)
#define BACKGROUND_WHITE (BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN)
#define BACKGROUND_YELLOW (BACKGROUND_RED | BACKGROUND_GREEN)
#define BACKGROUND_CYAN (BACKGROUND_BLUE | BACKGROUND_GREEN)
#define BACKGROUND_MAGENTA (BACKGROUND_RED | BACKGROUND_BLUE)
#define BACKGROUND_BLACK 0
#define BACKGROUND_INTENSE_RED (BACKGROUND_RED | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_GREEN (BACKGROUND_GREEN | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_BLUE (BACKGROUND_BLUE | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_WHITE (BACKGROUND_WHITE | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_YELLOW (BACKGROUND_YELLOW | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_CYAN (BACKGROUND_CYAN | BACKGROUND_INTENSITY)
#define BACKGROUND_INTENSE_MAGENTA (BACKGROUND_MAGENTA | BACKGROUND_INTENSITY)
There is no default mechanism to blink a character on screen. if you want this, it can be done by first reversing (exchanging) foreground and background attributes (COMMON_LVB_REVERSE_VIDEO) then setting a timer for the required blink period then reversing foreground and background attributes when timer triggers.
see the code:
Code:
void SetColorAndBackground(int ForgC, int BackC=0, bool Blink=false)
{
if (Blink==false)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|BackC );
}
else
{
for (;;)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|COMMON_LVB_REVERSE_VIDEO|BackC );
Sleep(1000);
}
}
}
what i'm doing wrong?
i try put some text before 'sleep()', but isn't blinking:(
i have another way, but i don't finish the MultiThread class:(
Re: [RESOLVED] can anyone tell me all colors const for SetConsoleTextAttribute() func
Set ConsoleText Attribute sets the attribute for text that follows on the screen. So if you put some text on the screen then call your function, you have to move the cursor back to the character you want to blink in your function before calling SetConsoleTextAttribute - or set the cursor back to the start of the text in the calling program.