Solved

Change Dlg text color..

Posted on 1998-12-13
2
307 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
[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
2 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 70 total points
ID: 1326149
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
ID: 1326150
Thank you it worked perfectly...
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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

728 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