How do you change the text or background color of your output?
Is there a FAQ on how to do that on this website somewhere?
How do you change the text or background color of your output?
Is there a FAQ on how to do that on this website somewhere?
HANDLE hStdout;
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_INTENSITY); //CHANGING TEXT COLOR
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
In some DOS compilers, you can...
Code:/*...some code here...*/ textbackgound(BLUE); clrscr(); /*...voila!...*/
Code:The SetConsoleTextAttribute function sets the foreground (text) and background color attributes of characters written to the screen buffer by the WriteFile or WriteConsole function, or echoed by the ReadFile or ReadConsole function. This function affects only text written after the function call. BOOL SetConsoleTextAttribute( HANDLE hConsoleOutput, // handle of console screen buffer WORD wAttributes // text and background colors ); Parameters hConsoleOutput Identifies a console screen buffer. The handle must have GENERIC_READ access. wAttributes Specifies the foreground and background color attributes. Any combination of the following values can be specified: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following combination of values produces white text on a black background: FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
Source: Win32 SDK Reference Help
Last edited by incognito; 03-10-2003 at 06:33 PM.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.