Solved

Change Dlg text color..

Posted on 1998-12-13
2
263 Views
Last Modified: 2013-11-20
I have a dialog based app. And on that I have for instance a check box. Now say I want that checkbox text color to be blue. Is that possible. I tried something like:
CDC *pDC = m_Check1.GetDC();
pDC->SetTextColor(RGB(0,0,255));
UpdateData(FALSE);
Nothing happens. Since I'm new at MFC there are ofcourse error somewhere, could somneone help me out??
Thanx...
0
Comment
Question by:Slask
2 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 70 total points
Comment Utility
Create a WM_CTLCOLOR message handler (OnCtlColor) with ClassWizard, which is called for any child control to recieve a brush for painting the controls.

in the OnCtlColor function add something like this:

  int index = pWnd->GetDlgCtrlID();
  switch ( index )
  {
    case(IDC_CHECK1):
      pDC->SetTextColor( RGB( 255, 0, 0 ) );
      break;
    case(IDC_CHECK2):
      pDC->SetTextColor( RGB( 0, 255, 0 ) );
      break;
    }

to set the textcolor of the CheckBoc IDC_CHECK1 to red and the textcolor of IDC_CHECK2 to green.

hope that helps,

ZOPPO
0
 

Author Comment

by:Slask
Comment Utility
Thank you it worked perfectly...
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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

772 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

10 Experts available now in Live!

Get 1:1 Help Now