ms123
ms123

Reputation: 31

change title bar color of mfc application

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

}

}

Upvotes: 3

Views: 3979

Answers (1)

xMRi
xMRi

Reputation: 15365

No doubt you could do this but it's almost surely a really bad idea to do so.

UI works well when it is predictable and consistent! The changes you are attempting make a UI non predictable and not consistent!

How will you deal with different OS versions, themed/unthemed, future versions of the OS that may be quite different in the way they paint non-client regions?

Using Google you find ways to do it like here

Upvotes: 3

Related Questions