Sign in to follow this  
evilsoft

Static controls in win32

Recommended Posts

I am working on a level creating application and am having problems with my Text Static controls. The backround color of the static is a bit lighter then the form color. Is there a way to change the back color of the static control to match the form color. Static control:
//Name Static
hNameLbl = CreateWindowEx (0,"Static","Name:",WS_CHILD|WS_VISIBLE|SS_SIMPLE,
                                75,55,50,20,hwnd,NULL,GetModuleHandle(NULL),NULL);

WinClass:
wincl.hInstance = hThisInstance;
wincl.lpszClassName = APPNAME;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);

wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;                 
wincl.cbClsExtra = 0;                      
wincl.cbWndExtra = 0;                      
wincl.hbrBackground = (HBRUSH)COLOR_MENU+3;

Share this post


Link to post
Share on other sites
Sorry for the ignorence, but what do I put in the handler to use the brush passed in the wparam?
I am fairly new to WIN32...I usually do tools, forms, etc in VB, so it is cake...but I found I like the control the winAPI offers, so I decided to take the C route.

Share this post


Link to post
Share on other sites
Quote:
Original post by xeddiex
SelectObject(wParam, CreateSolidBrush(#, #, #)); to set the brush color for the static controls device context. Then use GDI paint functions to paint.


Are the '#'s RGB values?

Share this post


Link to post
Share on other sites
CreateSolidBrush takes a COLORREF. That in turn is usually created by the RGB macro which takes red, green, and blue levels in the range of 0-255.

However, since you're not using an explicit color but are instead using a system color (COLOR_MENU + 3 to be exact, which is a really wierd thing to do, what are you actually trying to accomplish with that?) you should probably use GetSysColorBrush instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
CreateSolidBrush takes a COLORREF. That in turn is usually created by the RGB macro which takes red, green, and blue levels in the range of 0-255.

However, since you're not using an explicit color but are instead using a system color (COLOR_MENU + 3 to be exact, which is a really wierd thing to do, what are you actually trying to accomplish with that?) you should probably use GetSysColorBrush instead.


I started on COLOR_MENU+1 and kept incrementing and re-compling until I found the color I wanted..I found COLOR_APPWORKSPACE + 1 is the actual color I was looking for...Thanks for the function...works like a charm.

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