Solved

Changing colors of a CStatic

Posted on 1998-11-24
2
276 Views
Last Modified: 2013-11-20
Changing the font of a CStatic is pretty easy ..

fontBox=new CFont;
fontBox->CreateFont(16,0,0,0,600,0,0,0,
      ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
      DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"arial");
m_title.SetFont(fontBox);

But to change the color of the text it isn't so easy ...
I've been reading tons of help files and I couldn't find
anything useful. Any help is wellcome.      
0
Comment
Question by:econde
[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
2 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 100 total points
ID: 1325230
In the dialog override OnCtlColor (WM_CTLCOLOR), check for the id of your static control and set the color as you wish.

You can check the help for that message, it's pretty clear.
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1325231
To add to my answer, here's some code:

HBRUSH CDRegimes::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if( nCtlColor == CTLCOLOR_STATIC ) {
  if( pWnd->m_hWnd == GetDlgItem(IDC_YOUR_STATIC) ) {
    pDC->SetTextColor(RGB(100,100,100));
  }
}

return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}

It's something close to that.
0

Featured Post

Industry Leaders: 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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