[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Changing colors of a CStatic

Posted on 1998-11-24
2
Medium Priority
?
278 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 300 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

649 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