Solved

Changing colors of a CStatic

Posted on 1998-11-24
2
269 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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