Solved

Changing Checkbox Background Color

Posted on 2000-02-14
7
800 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now