Solved

Change text color of CStatic?

Posted on 1997-08-13
2
625 Views
Last Modified: 2013-11-20
Can you give me a code example of how to change
the text color of a CStatic in my dialog?
0
Comment
Question by:don23
[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 4

Accepted Solution

by:
davmarc earned 100 total points
ID: 1303679
Override OnCtlColor() in your derived CDialog class:

HBRUSH CYourDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    if (nCtlColor != CTLCOLOR_STATIC)
        return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    pDC->SetTextColor(THE_COLOR_YOU_WANT);
    return THE_BRUSH_YOU_WANT_FOR_BACKGROUND;
}

Davide Marcato.
0
 

Author Comment

by:don23
ID: 1303680
Aha, took me a couple of minutes to figure out the last two lines should mean something like:

 HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
 pDC->SetTextColor( RGB( 0, 0, 255) );
 return hbr;      

I kept setting text color, then calling
return CPropertyPage::OnCtlColor( yada, yada )

thanks much!
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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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…

734 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