How do you color a checkbox? Coloring the text of a checkbox is not a problem, but not the box itself. Success has been eluding me and I am not sure where to start.
How do you color a checkbox? Coloring the text of a checkbox is not a problem, but not the box itself. Success has been eluding me and I am not sure where to start.
SpEcIeS
Hmm I haven't tried this, but if one of the WM_CTLCOLOR messages doesn't handle checkboxes, you could always made an owner drawn box and just handle drawing it manually.
Unfortunatly this did not work for me, but perhaps I have not applied it correctly. My static text boxes work well with the WM_CTLCOLORSTATIC message, but after going through all of the messages I have come to a wall. (I even did the obvious ones that would not work)Hmm I haven't tried this, but if one of the WM_CTLCOLOR messages doesn't handle checkboxes, you could always made an owner drawn box and just handle drawing it manually.
Building my own checkbox sounds very complicated for me, and I really do not know where to start.
You input is greatly appreciated.
SpEcIeS
Yes, WM_CTLCOLORBTN was tried, but perhaps it was not applied correctly. Do you, or anyone else, have an example?Originally Posted by anonytmouse
SpEcIeS
For non-push button 'button' controls, like checkboxes, handle the parent's WM_CTLCOLORSTATIC. See also this page; the information is good for winxp, too.Code:case WM_CTLCOLORSTATIC: { int nID=GetDlgCtrlID((HWND)lParam); switch (nID) { case IDC_CHECKBOX: SetTextColor((HDC)wParam,RGB(255,0,0)); /*red*/ return (LRESULT)GetStockObject(LTGRAY_BRUSH); case IDC_ANOTHER_CHECKBOX: SetTextColor(HDC)wParam,RGB(0,255,0)); /*green*/ return (LRESULT)GetStockObject(BLACK_BRUSH); } }
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
Nice piece of code Ken. However, this was accomplished, but not in such a nice format. What I was looking for was the box its self being colored. For example: the check mark being yellow and the background to the box being black.
Perhaps I am faced with creating my own checkbox, and that sounds painful.
Thanks for your reply though. It was greatly appreciated.
SpEcIeS