change title bar color of mfc application

Viewed 2987

I want to change the title colour of my mfc application. I have used OnNcPaint() method.But the changes are done on client area instead of title bar.

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);

}

}

1 Answers
Related