james2432
asked on
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(..),[colo r]) in the WM_CREATE but it doesn't work. Please help.
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(..),[colo
//Register the window class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInst;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=CreateSolidBrush(RGB(195,217,250));//(HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName=NULL;
wc.lpszClassName=g_szClassName;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
//-----------------------------------------------------------------------------------------------------------------
//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);
ASKER
I don't really understand...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
More info:
1. here is a proposal (color checkbox class): http://www.codeguru.com/cp p/controls /controls/ checkboxco ntrols/art icle.php/c 5319
2. here is the same question (maybe interesting to read): http://www.eggheadcafe.com /forumarch ives/win32 programmer gdi/Sep200 5/post2367 4033.asp
1. here is a proposal (color checkbox class): http://www.codeguru.com/cp
2. here is the same question (maybe interesting to read): http://www.eggheadcafe.com
ASKER
Yeah this was WIN32..
Anyways i got the label(static) with WM_CTLCOLORSTATIC message
I set a brush to the background color
SetBkColor()
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
Anyways i got the label(static) with WM_CTLCOLORSTATIC message
I set a brush to the background color
SetBkColor()
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
ASKER
Because this is a win32api application I couldn't use MFC or AFX, but you set me on the right track
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,
ZOPPO