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
Solved

Change text color of CStatic?

Posted on 1997-08-13
2
606 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Execute multiple curl cmds with sleep and send output to file 10 104
changeXy challenge 13 88
mapBully challenge 6 152
Trying to run powershell  in a batch file. How do I do this? 8 105
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

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