How do you change the foreground/background color?
P.S. my compiler doesn't have <windows.h>.
How do you change the foreground/background color?
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.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 backgroundCode://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)
Last edited by The Brain; 04-12-2005 at 10:44 PM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
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.hDownload a compiler that has it.
E.g. Dev-C++
Download it here.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel