Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

Changing Checkbox Background Color

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

Tomas
0
tomsh
Asked:
tomsh
1 Solution
 
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
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
nietodCommented:
>> 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
 
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now