Static controls in win32

Started by
5 comments, last by evilsoft 18 years, 6 months ago
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;

Advertisement
You need to handle WM_CTLCOLORSTATIC.
-Mike
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.
SelectObject(wParam, CreateSolidBrush(#, #, #)); to set the brush color for the static controls device context. Then use GDI paint functions to paint.
one..
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?
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.
-Mike
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.

This topic is closed to new replies.

Advertisement