Q: Hi.
I am using AppWizard single document type setup. I must rectange of the Child View to get. The only thing I try to do the background color of the Child View. So ineed to get the exact size and location of the Child View in connection with the mainframe to gain. I tried using this:
—– * pwnd =
CWnd AfxGetMainWnd ();
CRect rectCView;
pWnd u003e-get (rectCView) *
CBrush pOldBrush, newBrush (RGB (0, 0, 0));
CDC * pDC = pwnd-u003e GetDC ();
pOldBrush PDC u003e = Select Property (u0026 newBrush)
pDC-u003e Rectangle (rectCView)
pDC u003e Select-Object (pOldBrush)
pWnd-u003e ReleaseDC (pDC) 977 503 —–
The problem with the code segment above is that all the repainting of the mainframe, including the toolbar and status bar. I would like to see the ChildView.
Thanks,
Kuphryn paint
Re:Okay. Thanks.
Kuphryn
Re:WM_ERASEBKGND is automatically sent to the window before it's repainted. You don't need to do anything.
Re:Both the Petzold and Prosise books describe WM_ERASEBKGND and Prosise has pages on OnEraseBkgnd. You can force a repaint by calling Invalidate(), e.g. pChild->Invalidate()
Re:Okay. As for WM_ERASEBKGND, how do I start the message (i.e. have windows send the ChildView the WM_ERASEBKGND message)?
I am not familiar with WM_ERASEBKGND at all.
Kuphryn
Re:Nice! Thanks.
Kuphryn
Re:No difference between RGB amd PALETTERGB *if* your desktop is set to 16-bit/24-bit color (no palette).
In the programming nightmare that is 256-color mode every running application fights for control of what shades are set for 236 of those colors. Then if your app is using a palette to control some colors you need PALETTERGB to find one of your custom colors. You should probably ignore all of this and just use RGB() instead
dc.GetClipBox(&invalid_rect); returns the smallest rectangle that encloses all of the invalid parts of the window. For example if you've closed a messagebox and it was only covering part of your view window then only part of the window is invalid / in need of repainting. Using this instead of GetClientRect is a little faster since less screen clipping is needed.
Re:Add WM_ERASEBKGND handler to the view class and have it set the background color to whatever you want.
Re:Thanks!
Nice!
I have two questions.
First, in this line:
—–
CBrush cream(PALETTERGB(224,224,224));
—–
Is that the same as this?
—–
CBrush cream(RGB(224, 224, 224));
—–
Lastly, what does this line do?
—–
dc.GetClipBox(&invalid_rect);
—–
Kuphryn
Re:Normally you have the child window paint itself the proper color, by handling either the WM_PAINT message (CFormView or CDialog window) or WM_ERASEBKGND (CView). e.g.
void CSideEditFormView : : onPaint()
{
CPaintDC dc(this); // device context for painting
CBrush cream(PALETTERGB(224,224,224));
CRect invalid_rect;
dc.GetClipBox(&invalid_rect);
dc.FillRect(&invalid_rect, &cream);
}
0 Comments.