Solved

Changing Checkbox Background Color

Posted on 2000-02-14
7
818 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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