Solved

Changing Checkbox Background Color

Posted on 2000-02-14
7
809 Views
Last Modified: 2008-02-20
Hello ,
I would like to know , how can i change the Background Color for my CheckBoxs ?

Tomas
0
Comment
Question by:tomsh
7 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2519748
What OS?

Windows?  Handle the WM_CTLCOLORBTN message.
0
 
LVL 3

Expert Comment

by:akalmani
ID: 2521131
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
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2521847
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2522452
>> 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
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2522564
nietod - yes of course, got confused about which group I was in.

Apologies :)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2522721
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
 

Author Comment

by:tomsh
ID: 2526035
Thanks for your help, Neitod :)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question