tomsh
asked on
Changing Checkbox Background Color
Hello ,
I would like to know , how can i change the Background Color for my CheckBoxs ?
Tomas
I would like to know , how can i change the Background Color for my CheckBoxs ?
Tomas
HI !!
Neitod is right handle the WM_CTLCLR and in that function return the particular brush u want. That will change the color of the background.
There are 2 ways either u can derive a class from CButton and overrride the WM_CTLCLR and write there or if u are handling in the Dialog class itself then u have to check for the control id of that check box
e.g if(pWnd->GetDlgCtrlId() == ID_MYCHECKBOX)
{
CBrush MyBrush(RGB(255,0,0));
return MyBrush;
}
Neitod is right handle the WM_CTLCLR and in that function return the particular brush u want. That will change the color of the background.
There are 2 ways either u can derive a class from CButton and overrride the WM_CTLCLR and write there or if u are handling in the Dialog class itself then u have to check for the control id of that check box
e.g if(pWnd->GetDlgCtrlId() == ID_MYCHECKBOX)
{
CBrush MyBrush(RGB(255,0,0));
return MyBrush;
}
Rather than handle WM_CTRL colour for each child of you window - handle it in the main window with:
ON_WM_CTLCOLOR_REFLECT( ) afx_msg HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor );
ON_WM_CTLCOLOR_REFLECT( ) afx_msg HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor );
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
nietod - yes of course, got confused about which group I was in.
Apologies :)
Apologies :)
No appology needed, I just don't want to see anyone get confused. tomsh may be programming on the mac or in the windows API and may find your suggestion a little hard to use.
ASKER
Thanks for your help, Neitod :)
Windows? Handle the WM_CTLCOLORBTN message.