Sign in to follow this  
willthiswork89

few questions on win api

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
CreateSolidBrush()
:) Got to go to class...

Edit:
ex:
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this