Any code examples? Here is my current code.
Thanks,
Brad
void CWizVer3View::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
CBrush* pBrush = new CBrush(WIZ3_BK_BLUCOLOR);
// Select the new brush into the DC.
CBrush* oldBrush = dc.SelectObject(pBrush);
// Draw the rectangle.
dc.FillRect(rect, pBrush);
// Restore the DC and delete the brush.
dc.SelectObject(oldBrush);
delete pBrush;
// Do not call CFormView::OnPaint() for painting messages
}
you could try returning TRUE from the OnEraseBkgnd handler.
some rough code:
OnPaint()
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(somePen);
...draw whatever into memDC
memDC.SelectStockObject(BLACK_PEN) //deselect pen to avoid mem leak
dc.bitblt(0,0, screenwidth, screenheight, &memDC 0, 0, SRCCOPY
}
I think that's it
In article <01c03479$1fc70e00$0610210a@paloverde>,
"Information Systems" <b...@cherry-semi.com> wrote:
>
> I have an MDI application that uses 2 CFormView's. I am noticing a
great
> deal of flicker when I switch views. What is the best way to avoid
this
> flicker when switching views?
>
> Any code examples? Here is my current code.
>
> Thanks,
>
> Brad
>
> void CWizVer3View::OnPaint()
> {
> CPaintDC dc(this); // device context for painting
> CRect rect;
> GetClientRect(rect);
>
> CBrush* pBrush = new CBrush(WIZ3_BK_BLUCOLOR);
> // Select the new brush into the DC.
> CBrush* oldBrush = dc.SelectObject(pBrush);
> // Draw the rectangle.
> dc.FillRect(rect, pBrush);
> // Restore the DC and delete the brush.
> dc.SelectObject(oldBrush);
>
> delete pBrush;
>
> // Do not call CFormView::OnPaint() for painting messages
> }
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
The reason it is flickering is that:
1) Windows is calling your OnEraseBackground().
2) By default, OnEraseBackground() calls DefWindowProc which paints the
entire window using the brush defined in the CLASSINFO used to create the
window.
3) Windows calls your OnPaint() function which again paints the entire window
a different color.
The flash occurs because you can briefly see the painting as a result of Step
#2 prior to the painting in step #3.
To eliminate, modify the behavior of step #2 by either:
a) Creating the window using a NULL brush
b) Override OnEraseBackground() to return TRUE so that Defwindowproc doesn't
paint anything.
David Ching, Windows Consultant
http://www.dcsoft.com