few questions on win api

Started by
2 comments, last by KittyRa 18 years, 7 months ago
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?
Advertisement
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 grayWndClass.cbBackGround = (HBRUSH) GetStockObject(GRAY_BRUSH);// This will set background to light grayWndClass.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.
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.
-Mike
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]
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!

This topic is closed to new replies.

Advertisement