Changing the background color of a check box... 
Author Message
 Changing the background color of a check box...


Thank you in advance,

Jeremy

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.*-*-*.com/ ;  The website for Visual C++ programmers.



Sun, 28 Oct 2001 03:00:00 GMT  
 Changing the background color of a check box...
Jeremy,

You will find your answer in CWnd::OnCtlColor

Chris Childs
Software Engineer



Sun, 28 Oct 2001 03:00:00 GMT  
 Changing the background color of a check box...
Jeremy,

In order to add change the background color of a check box, bring up the
Class Wizard for the Dialog that has the check box you want altered. Under
Messages, Select the WM_CTLCOLOR item and add a function. You will have to
add a switch statement in order to filter out the type of control that you
want. If you want to single out a specific control, then use the CWnd
pointer to determine if you have the control that you want. Then use the
appropriate color function.

I have included the header for one of my versions of the command. I was
doing a null pointer in the background to allow the textured background show
through. But that's a whole other story.

Hope that this helps.

Chris Childs
Software Engineer

/* *****  *****  *****  *****  *****  *****  *****  *****  *****  *****
Function : OnCtlColor()

Purpose  : Paint a control when asked to.

Params   :
     CDC  *pDC  - Contains a pointer to the display context for the child
window. May be temporary.
     CWnd *pWnd  - Contains a pointer to the control asking for the color.
May be temporary.
     UINT nCtlColor - Contains one of the following values, specifying the
type of control:

Return   : HBRUSH.

Notes    : nCtlColor can be
     CTLCOLOR_BTN  Button control
     CTLCOLOR_DLG  Dialog box
     CTLCOLOR_EDIT  Edit control
     CTLCOLOR_LISTBOX List-box control
     CTLCOLOR_MSGBOX  Message box
     CTLCOLOR_SCROLLBAR Scroll-bar control
     CTLCOLOR_STATIC  Static control

   *****  *****  *****  *****  *****  *****  *****  *****  *****  ***** */

HBRUSH CFormView_Routing::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     switch(nCtlColor)
     {
          case CTLCOLOR_SCROLLBAR :
          case CTLCOLOR_EDIT : // Don't use transparent backgrounds with
edit controls. It's not very nice.
               return CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
               break;
          default :
               pDC->SetBkMode(TRANSPARENT);
               pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));

               CBrush Nothing;
               Nothing.CreateStockObject(NULL_BRUSH);
               return Nothing;
               break;
     }

Quote:
}



Fri, 02 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Changing background color of a group box

2. Change background color of dialog box title

3. changing background color of a message box?

4. Change Dialog Box Background Color

5. Change background color of a Dialog box?

6. How to change the background color of an edit box

7. I would like to change the background color of a dialog box

8. change background color of drop down list box

9. Change background color of a Dialog box?

10. how change the color of check box?

11. Changing the Background Color of a Dialog to match the background of a Bitmap

12. Change the background color of a dialog box and change text color of Edit Box, Static Text, Rich Edit

 

 
Powered by phpBB® Forum Software