Solved

Change text color of CStatic?

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now