Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specify Coloru for Specific Labels 1

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
0
0
GB
I wish to change the background and foreground colour of 4 labels on a dialog.

I can use OnCtlColor, but it changes all the static text and Check boxes on the dialog.

i.e.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC)
{
//if(g_pTabFiveDlg->GetDlgItem (
pDC->SetBkColor(BLACK_BRUSH);
pDC->SetTextColor(RGB(255,255,0));
return (HBRUSH)GetStockObject(BLACK_BRUSH);
}

How can I just arrange for specific labels to be affected?
 
Use the window pointer to get the specific window identifier like this.

if(pWnd->GetDlgCtrlID()==IDC_CAL_NAME)
{
pDC->SetTextColor(colorStatic);
}

Then you can distinguish between the different windows on your dialog.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top