|
-
September 10th, 1999, 05:46 AM
#1
coloring window
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.
-
September 10th, 1999, 06:08 AM
#2
Re: coloring window
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.
-
September 13th, 1999, 02:35 AM
#3
Re: coloring window
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.
-
September 13th, 1999, 04:50 AM
#4
Re: coloring window
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|