我想更改mfc应用程序的标题颜色。我使用过OnNcPaint()方法。但是更改是在客户区而不是标题栏上完成的。
void CTitleBarColorView::OnNcPaint()
{
CRect rc;
GetWindowRect(&rc);
CWindowDC dc(this);
rc.top = GetSystemMetrics(SM_CYFRAME);
rc.right = rc.Width() - 2;
rc.left = GetSystemMetrics(SM_CXFRAME);
rc.bottom =GetSystemMetrics(SM_CYCAPTION);
for (int i = 2; i < rc.Width() - 2; i++)
{
double color;
CPen* oldPen;
color = 200 * (double)i;
CPen pen(PS_SOLID, 1, RGB(0, 0, (int)color));
dc.MoveTo(i, 1);
oldPen = dc.SelectObject(&pen);
dc.LineTo(i, rc.bottom-1);
dc.SelectObject(oldPen);
}
}