
Changing the background color of a check box...
Jeremy,
In order to add change the background color of a check box, bring up the
Class Wizard for the Dialog that has the check box you want altered. Under
Messages, Select the WM_CTLCOLOR item and add a function. You will have to
add a switch statement in order to filter out the type of control that you
want. If you want to single out a specific control, then use the CWnd
pointer to determine if you have the control that you want. Then use the
appropriate color function.
I have included the header for one of my versions of the command. I was
doing a null pointer in the background to allow the textured background show
through. But that's a whole other story.
Hope that this helps.
Chris Childs
Software Engineer
/* ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
Function : OnCtlColor()
Purpose : Paint a control when asked to.
Params :
CDC *pDC - Contains a pointer to the display context for the child
window. May be temporary.
CWnd *pWnd - Contains a pointer to the control asking for the color.
May be temporary.
UINT nCtlColor - Contains one of the following values, specifying the
type of control:
Return : HBRUSH.
Notes : nCtlColor can be
CTLCOLOR_BTN Button control
CTLCOLOR_DLG Dialog box
CTLCOLOR_EDIT Edit control
CTLCOLOR_LISTBOX List-box control
CTLCOLOR_MSGBOX Message box
CTLCOLOR_SCROLLBAR Scroll-bar control
CTLCOLOR_STATIC Static control
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** */
HBRUSH CFormView_Routing::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch(nCtlColor)
{
case CTLCOLOR_SCROLLBAR :
case CTLCOLOR_EDIT : // Don't use transparent backgrounds with
edit controls. It's not very nice.
return CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
break;
default :
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
CBrush Nothing;
Nothing.CreateStockObject(NULL_BRUSH);
return Nothing;
break;
}
Quote:
}