Changing Checkbox Background Color

Hello ,
I would like to know , how can i change the Background Color for my CheckBoxs ?

Tomas
tomshAsked:
Who is Participating?
 
nietodConnect With a Mentor Commented:
>> ON_WM_CTLCOLOR_REFLECT( ) afx_msg
>> HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor );
There is no indicatation the question is for Windows, much less for MFC.
0
 
nietodCommented:
What OS?

Windows?  Handle the WM_CTLCOLORBTN message.
0
 
akalmaniCommented:
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;
      }
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ScottyDawgCommented:
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 );

0
 
ScottyDawgCommented:
nietod - yes of course, got confused about which group I was in.

Apologies :)
0
 
nietodCommented:
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.
0
 
tomshAuthor Commented:
Thanks for your help, Neitod :)
0
All Courses

From novice to tech pro — start learning today.