|
He uses WM_CTLCOLORBTN for message reflection to modify the background color of the control
This cannot meet your requirements in MFCGridCtrl
Try the method I said for yourself
Replace this code
CString strText = GetText();
CString strTemp = strText.Left(1);
if (strTemp == "1")
{
CSize szText = pDC->GetTextExtent( strTemp );
for (int x = 0; x <strText.GetLength(); x++)
{
strTemp = strText.Mid(x, 1);
rect.left += szText.cx*x;
if (x% 2)
{
pDC->SetTextColor( 0x00ff0000);
} else
{
pDC->SetTextColor( 0x0000ff00);
}
DrawText(pDC->m_hDC, strTemp, -1, rect, GetFormat() | DT_NOPREFIX);
}
} else DrawText(pDC->m_hDC, GetText(), -1, rect, GetFormat() | DT_NOPREFIX);
The original
DrawText(pDC->m_hDC, GetText(), -1, rect, GetFormat() | DT_NOPREFIX);
See if the characters in the demo are displayed in color? |
|