How do you change the foreground/background color? :confused:
P.S. my compiler doesn't have <windows.h>. :(
Printable View
How do you change the foreground/background color? :confused:
P.S. my compiler doesn't have <windows.h>. :(
You should look into getting the windows library if you are into doing all this fancy shmancy stuff.Quote:
P.S. my compiler doesn't have <windows.h>.
win32API:
Code://You can set background color when you set the wndclass.hbrBackground attribute
wndclass.hbrBackground = CreateSolidBrush(0); //All black background
Code://Also, you can always create a new brush and insert the handle in the window class
//structure and then delete the old brush anytime you want to change background color:
DeleteObject((HBRUSH)
SetClassLong(hwnd, GCL_HBRBACKGROUND,
(LONG)CreateSolidBrush(RGB(color[0], color[1], color[2]))));
//The next time windows recolors the background of the window, it will use this new brush
Here is some example winAPI code that nicely demonstrates how to change background color. (too bad you don't have windows.h, maybe one of your friends can compile it and give it to you)
Where can I get a windows library?
Download a compiler that has it.
E.g. Dev-C++
I am guessing Cool-August is using the console, which means the above code will not work. As far as I'm awear, there is no 'non-hackerish' way to change the color of the console screen. Yet I am not certain.
See this thread. In it, adrianxw posts a link for his tutorial which covers colour....unfortunately windows.h would is needed so you should definitely try to download it.
http://cboard.cprogramming.com/showt...hlight=console
Cheers
Starkhorn
On a Windows machine, the following code will change the text in a console application green (my favorite console color):
The system() function take that string and passes it along to Windows's Command Prompt for it to run. You can use "help color" to find the values for all the colors.Code:system("color a");
Just remember that this is only for Windows, and the system() function's behaviour is platform-dependant.
I think the bloodshed IDE supports windows.hQuote:
Download a compiler that has it.
E.g. Dev-C++
Download it here.