changing label text color

It's very smple question but I can't find solution.

I wanted to use a differnt style label, so changed
the font and font size, but couldn't change text
colot and background color.

It's there any suggestion?
worker018Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
What is a label?
0
mikeblasCommented:
You can't set this in the dialog editor.

At runtime, you need to handle WM_CTLCOLOR for the control and set its color that way.  That means you need to give the control a real ID, and not IDC_STATIC (which is -1).

..B ekiM
0
mikeblasCommented:
Here's a code framgnet:

HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
   HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

   if (pWnd->GetDlgCtrlID() == IDC_FOO)
   {
      pDC->SetTextColor(RGB(255, 0, 0));
   }

   return hbr;
}


Obviously, you'll use whatever ID you want in place of IDC_FOO. Also, you can pick any color; I used RGB(255, 0, 0) which is red.

..B ekiM
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

chensuCommented:
Is worker018 talking about a static control?
0
mikeblasCommented:
> Is worker018 talking about a static control?
 
I would say so.  Some Windows environments call 'em labels.

..B ekiM
0
worker018Author Commented:

Oh sorry, I mean static control.
but, I can't understand how can I use your code

==========================================
HBRUSH CScan04Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{                        
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

      if (pWnd->GetDlgCtrlID() == IDC_FOO){
            pDC->SetTextColor(RGB(255,0,0));
      }
      return hbr;
}

===========================================

I inserted this code in my dialog, and wrote the header file.
and replace IDC_FOO to IDC_POSITION (my control name)
what can I do next?
0
worker018Author Commented:

Oh sorry, I mean static control.
but, I can't understand how can I use your code

==========================================
HBRUSH CScan04Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{                        
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

      if (pWnd->GetDlgCtrlID() == IDC_FOO){
            pDC->SetTextColor(RGB(255,0,0));
      }
      return hbr;
}

===========================================

I inserted this code in my dialog, and wrote the header file.
and replace IDC_FOO to IDC_POSITION (my control name)
what can I do next?
0
ZoppoCommented:
Hi worker018,

take a look at http://www.codeguru.com/staticctrl/label_static.shtml for a extended CStatic derived class code and sample ...

hope that helps,

ZOPPO
0
mikeblasCommented:
> what can I do next?

Assuming you've correctly edited the header file, you should be all set.

Are you getting any errors? What's stnding in your way? Please be specific.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
worker018Author Commented:

 Thanks for your answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.