Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change text color of CStatic?

Posted on 1997-08-13
2
Medium Priority
?
640 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 300 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

972 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