We have embedded a grid window into a CView. Whenever the view is drawn, the grid window gets erased and we get a lot of flickering. What can we do?
The problem is that the view will erase the grid in its OnEraseBkgnd message. You should process this message and also override the OnPaint message.
Example:
BOOL CWndView::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
}
void CWndView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Erase everything but not the grid
CRect rectGrid;
m_pMeasTable->GetWindowRect(rectGrid);
ScreenToClient(&rectGrid);
dc.ExcludeClipRect(rectGrid);
CRect rectClient;
GetClientRect(rectClient);
GXPatB(&dc, rectClient, ::GetSysColor(COLOR_WINDOW));
}
Take also a look at the other FAQs in the section "Drawing and Flickering".