Doe's anyone know how to add colour to DOS programs? I use C++ and I would like to know how to use colour instead of the boring white text as usual. If you know then please post how to on this board and show some source code!
Doe's anyone know how to add colour to DOS programs? I use C++ and I would like to know how to use colour instead of the boring white text as usual. If you know then please post how to on this board and show some source code!
Include conio.h. Then use the following function:
textcolor(int color)
That will change the text color, but it does not come into effect unless you clear the screen:
clrscr();
So, here is some example code:
#include <iostream.h>
#include <conio.h>
int main (void)
{
textcolor(RED);
clrscr();
cout << "Hello, World!";
getch();
return 0;
}
It (textcolor()) does come into effect, but you have to use the right functions. I think all output functions that use direct access will work (putch(), cprintf(), etc...).
to prevent confuson i'll ask first, are you usin a console?
Last edited by no-one; 09-30-2001 at 11:13 AM.
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
I am using a console and not a GUI program.
repost,
the colors can be mixed
FOREGROUND_BLUE Text color contains blue.
FOREGROUND_GREEN Text color contains green.
FOREGROUND_RED Text color contains 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.
Code:#include <windows.h> int main() { HANDLE hStdout; hStdout = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hStdout, FOREGROUND_RED); printf("WWWWOOOOO MY TEXT IS RED WWOOOOO!!"); return 0; }
Last edited by no-one; 10-01-2001 at 10:02 AM.
Ah, I don't do C++, so I was wondering about doing the eqivulent in C? I'm not really aware of any functions that can do that in C. Any comments would be apperciated....
Thanks.
that is C, it should work fine...
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.