Advertisement Jump to content
Sign in to follow this  

few questions on win api

This topic is 4887 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

okay when you do WINCLASS WndClass; WndClass.cbBackGround = (HBRUSH) (COLOR_WINDOW+1); excuse my sytax...but is there a pallete somewhere so i can change the color...the plus one is white...and im not sure what the other colors are?

Share this post

Link to post
Share on other sites
Other colors:

#define BLACK_BRUSH 4
#define DKGRAY_BRUSH 3
#define GRAY_BRUSH 2
#define LTGRAY_BRUSH 1
#define WHITE_BRUSH 0

Took that from a header file, but MSDN reference is also avaliable.

Now to use brushes:

// This will set background to gray
WndClass.cbBackGround = (HBRUSH) GetStockObject(GRAY_BRUSH);

// This will set background to light gray
WndClass.cbBackGround = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

Now if you want a custom color you could use the methods of painting a rectangle over the background in the WM_PAINT message handeling. Look here for that.

I'm not sure if there's a way to set the background color to another color using the WndClass.cbBackGround, I don't use GDI. Anyways, good luck with your project.

Share this post

Link to post
Share on other sites
The +1 is not white. COLOR_WINDOW+1 is white on your machine because thats what you have your window color set to. Right-click your desktop, select properties, change your window color to blue (say) and now when you run your app it will start drawing blue instead of white. The docs for WNDCLASS talk about this in some detail.

If you want some specific color you need a brush of that color. GetStockObject has a few standard colors (e.g. BLACK_BRUSH) or you can use CreateSolidBrush to create a brush of whatever color you might want.

Share this post

Link to post
Share on other sites
you can use the RGB() macro with
:) Got to go to class...

WndClass.cbBackGround = CreateSolidBrush(RGB(0,0,0));

[Edited by - DigiDude on September 7, 2005 10:37:12 AM]

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!