• Advertisement
Sign in to follow this  

What is COLOR_WINDOW + 1

This topic is 4046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What does this do, and what does COLOR_WINDOW mean wndclass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ) Thanks, Glen http://cavelectronics.tripod.com

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement