What is COLOR_WINDOW + 1

Started by
13 comments, last by Colin Jeanne 17 years ago
What does this do, and what does COLOR_WINDOW mean wndclass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ) Thanks, Glen http://cavelectronics.tripod.com
** boolean010 **
Advertisement
It is a member of the WNDCLASS or WNDCLASSEX structure that describes the background of a window using that window class. The COLOR_WINDOW + 1 bit of that line says that the background color of a window using that window class should be a system color; that gives the advantage that when a user changes the color scheme on his/her computer, the color you used will change as well if I'm not mistaken. Just experiment with the addition to COLOR_WINDOW and see what kind of colors you can get :P
Quote:Original post by rogierpennink
Just experiment with the addition to COLOR_WINDOW and see what kind of colors you can get :P

Instead of experimenting to see what works (and having no idea why or what implications your experiment has) you could check the documentation to see what colors exist.
But why do you need to add 1 to the color.
Someone who uses a, euhm..., delta!?
Quote:Original post by delta user
But why do you need to add 1 to the color.


because microsoft says so.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Quote:Original post by Colin Jeanne
Quote:Original post by rogierpennink
Just experiment with the addition to COLOR_WINDOW and see what kind of colors you can get :P

Instead of experimenting to see what works (and having no idea why or what implications your experiment has) you could check the documentation to see what colors exist.

That's undisputedly a good resource but I don't see what's wrong with a little experimenting either. In a worst-case scenario your program will crash and you will have to investigate what went wrong. Such investigation often leads to understanding and valuable experience. If nobody experimented and 'checked the documentation' only, we probably wouldn't even be able to discuss this on computers over the internet...

Quote:Original post by boolean010
What does this do, and what does COLOR_WINDOW mean

wndclass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 )


That's either a really fucked up API or very bad coding style ;-)

Check the docs as Colin says, and if there aren't any constants to use, better create some. COLOR_WINDOW + 1 is nonsense.
Quote:Original post by rogierpennink
In a worst-case scenario your program will crash and you will have to investigate what went wrong.

No, that's the best-case scenario. If you've done much software debugging, you'll know what I mean.
Quote:Original post by Sneftel
Quote:Original post by rogierpennink
In a worst-case scenario your program will crash and you will have to investigate what went wrong.

No, that's the best-case scenario. If you've done much software debugging, you'll know what I mean.

I won't challenge you on that, undoubtedly you have done more software debugging than I have. On the other hand, this is a thread by someone who is apparently learning the win32 API. I may be wrong again, but when I was learning such basics (yes, I experimented with the values for hbrBackground as well) nothing unrepairable would happen. I'm fairly confident that a little experimenting on the OP's part won't hurt too much and it might as well be a learning experience. "I had better not do this again or my program won't work!" - sort of experiences...

Quote:Original post by Ahnfelt
Quote:Original post by boolean010
What does this do, and what does COLOR_WINDOW mean

wndclass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 )


That's either a really fucked up API or very bad coding style ;-)

both.
Quote:
Check the docs as Colin says, and if there aren't any constants to use, better create some. COLOR_WINDOW + 1 is nonsense.

it is nonsense. looking here you'll see that COLOR_WINDOW + 1 would be COLOR_WINDOWFRAME.

edit: apparently the code is right and only the api is nonsense. evil steve explained below.

[Edited by - gumpy macdrunken on March 25, 2007 10:55:19 PM]
This space for rent.

This topic is closed to new replies.

Advertisement