Checkbox/static color

I've colored my window :RGB(195,217,250)

And I have created a static and a checkbox in my WM_CREATE but they come out that there is a grey rectangle arround the text I was wondering how to color it the same as the solidbrush of the window, I've tried doing SetBkColor(GetDc(..),[color]) in the WM_CREATE but it doesn't work. Please help.

//Register the window class
	wc.cbSize = sizeof(WNDCLASSEX); = 0;
	wc.lpfnWndProc = WndProc;
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
//create seach label
	hwndlblSearch = CreateWindowEx(0,TEXT("static"),TEXT("Table/View name"),SS_LEFT|WS_CHILD|WS_VISIBLE,33,10,116,17,hwnd,(HMENU)lblSearch,NULL,NULL);
//Checkbox Table
	hwndcbTable = CreateWindowEx(0,TEXT("BUTTON"),TEXT("Table"),BS_AUTOCHECKBOX|WS_VISIBLE|WS_CHILD,265,32,100,25,hwnd,(HMENU)cbTable,NULL,NULL);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi james2432,

IMO there's no easy solution for this - the problem simply is that a standard checkbox just draws the text in none-transparent (opaque) drawing mode, so the background of the text is always filled with the background color (GetBkColor) of the DC used for its drawing.

You could try to replace the WndProc of the checkbox (with SetWindowLong) with one of your own which handles WM_PAINT message in a way it modifies the DC's (you can retrieve it with GetDC) text drawing mode to TRANSPARENT (SetBkMode), then call it's original WndProc (CallWndProc) and, if needed, afterwards restore the previous drawing mode.

Hope that helps,

james2432Author Commented:
I don't really understand...
Zoppo said that the easiest way to implement your idea is to make your own control that will know how to draw itself.
Once we tried to do that without own control - terrible - set a hook was really not easy.
It's about the checkbox.
"static" means a text label - CStatic? if yes, look on this site for WM_CTLCOLOR or for OnCtlColor.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

More info:
1. here is a proposal (color checkbox class):
2. here is the same question (maybe interesting to read):
james2432Author Commented:
Yeah this was WIN32..

Anyways i got the label(static) with WM_CTLCOLORSTATIC message
I set a brush to the background color
SetBkMode() to transparent
and returned the brush I created

the checkbox dispite being a "BUTTON" seeing as it's static text it can be done via same WM
the same goes for a groupbox

No need for subclassing
Thank you
james2432Author Commented:
Because this is a win32api application I couldn't use MFC or AFX, but you set me on the right track
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.