Solved

Change text color of CStatic?

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 162
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 184
wordcount challenge 11 144
Thin secure Windows 10 5 107
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 …
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…
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.

680 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