Solved

Changing colors of a CStatic

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

839 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