I have a dialog based application in VC++5.0
I use mfc.
I have to change the entire window color at a button click e.g.
I use OnCtlColor but the frames (thick borders)remains unchanged, in the same gray color.
Please help me.
Printable View
I have a dialog based application in VC++5.0
I use mfc.
I have to change the entire window color at a button click e.g.
I use OnCtlColor but the frames (thick borders)remains unchanged, in the same gray color.
Please help me.
You must paint the borders of a window in the function OnNcPaint(), because the borders don't belong to the windows client area and OnCtlColor only works for the client area.
I've implemented OnNcPaint() but the frames are becaming transparent.
How should look the implementation?
I've tried
CPaintDC dc(this); // device context for painting
CBrush ncbrush;
ncbrush.CreateSolidBrush(RGB(255,255,0));
dc.FillRect(NULL, &ncbrush);
but it doesn't vork.
thank you.
You must use CWindowDC instead of CPaintDC. CPaintDC may only be used in OnPaint. And you must give the rectangle to paint in for the FillRect function.
CWindowDC dc(this);
CBrush brush;
CRect rc;
brush.CreateSolidBrush(RGB(255, 255, 0));
GetWindowRect(&rc); // paint whole non-client area in desired color
rc.OffsetRect(-rc.left, -rc.top);
dc.FillRect(&rc, &brush);
// you must also draw the caption bar yourself...