473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

colors

3
Hi there, how can i make a background color in a C program? Must i use structures or unions?
Nov 8 '08 #1
8 1799
weaknessforcats
9,208 Expert Mod 8TB
There's more to this than you suppose.

First, what operating system?

Second, you need a window before you can have a background color.

Assuming you have Windows and know how to create a window, then the backgound color can be set with http://msdn.microsoft.com/en-us/libr...61(VS.85).aspx.
Nov 8 '08 #2
boxfish
469 Expert 256MB
At least on windows, you can change the colors of your program's console window by calling an operating system specific command with the system function. If you are running windows, you can type "help color" into the command prompt to get information on the command.
system("color 6D");
Nov 8 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
I didn't know you could do that. Nice reply.
Nov 8 '08 #4
boxfish
469 Expert 256MB
Thanks. You can also do this by right-clicking on the title bar of the command prompt window and clicking on properties. It lets you choose all sorts of things about your command prompt window.
Nov 8 '08 #5
jivko
3
There's more to this than you suppose.

First, what operating system?

Second, you need a window before you can have a background color.

Assuming you have Windows and know how to create a window, then the backgound color can be set with http://msdn.microsoft.com/en-us/libr...61(VS.85).aspx.
operation system is windows xp, i use quincy compiler. What is wrong with the line 17 ...load Icon?
//line 0
#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[]= "MyWin";
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE
hPrevInst, LPSTR lpszArgs,
int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
wcl.cbSize=sizeof(WNDCLASSEX);
wcl.hInstance=hThisInst;
wcl.lpszClassName=szWinName;
wcl.lpfnWndProc=WindowFunc;
wcl.style=0;
wcl.hIcon = LoadIcon(NULL,IDI_APPLICATION);
//стил на иконата
wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
//стил на малката икона
wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
//стил на курсора
wcl.lpszMenuName=NULL;
wcl.cbClsExtra=0;
wcl.cbWndExtra = 0;
//цветът на фона на прозореца да бъде бял
wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
//регистриране на класа на прозореца
if(!RegisterClassEx(&wcl)) return 0;

hwnd = CreateWindow(
szWinName, "Windows Skeleton", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, HWND_DESKTOP, NULL,hThisInst, NULL);

ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
Nov 10 '08 #6
arnaudk
424 256MB
What error do you get? It would help if you used [CODE] ... [/code] tags as this code is hardly legible.
Nov 10 '08 #7
jivko
3
"Undefined reference to LoadIcon". The compilation is ok, the linkage can not work.
Nov 10 '08 #8
Banfa
9,065 Expert Mod 8TB
But you don't have a problem with LoadCursor?

Try calling LoadImage instead (of either or both of them).
Nov 10 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: aznFETISH | last post by:
I have a list of links that I ue on my page, I alternate background colors for these links in a table, I usually do it using a DB but this list of link is manually added into the page so my...
7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
5
by: Dan Jacobson | last post by:
What's Nielsen talking about in http://www.useit.com/alertbox/20040503.html http://www.useit.com/alertbox/20040510.html Can't a good browser keep track of visited vs. unvisited link colors? Is my...
3
by: Marc | last post by:
Hi, maybe you guys know something I don't know... Is it possible (and how) to achieve the following: 1) A <BODY> with specific background-color, say blue. 2) A <DIV class='main'> (which...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
0
by: mark | last post by:
Somebody can explain me why if I put a color with SetPixel the color showed is of another value? For example: I've to draw a grayscale image. The color RGB(90,90,90) become RGB(40,45,60). In the...
6
by: Mark | last post by:
Is there a programatic way to iterate through all the named colors? Something like: HtmlTable ht = new HtmlTable(); HtmlTableRow htr; HtmlTableCell htc; foreach (Color c in ) //I CAN'T FIND...
11
by: Paul Smith | last post by:
I have a button on my web page the backcolor of which I want to change: btnSample.backcolor = ???????? I want the color to be Gainsboro However I enter Gainsboro or color.Gainsboro I have...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
5
by: Stick | last post by:
Hi, I normally program in C++, and I'm trying to write this little tool in C#, but I quickly realized that I can't use pointers, so instead I need to create an array of 3 Color 's private...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shжllоpфpп 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.