title: MFC Redraw window in paint application problem
body: <p>I'm trying to write Paint on MFC but I have a problem with redrawing window while draw new figures, move or resize existing ones. When I use <code>Invalidate()</code> or <code>InvalidateRect(NULL)</code> after every mouse move it is good but after adding 3-4 figures application crashes because it can't redraw all window in time. I've tried <code>InvalidateRect(FigureRect)</code> and <code>RedrawWindow(FigureRect)</code> but it doesn't work correctly (smears appear).</p>
  
  <p>That works good but app crashes:</p>
  
  <pre><code>void CGraphicsEditorView::OnMouseMove(UINT nFlags, CPoint point)
  {
      ...
      if (m_mouseDrugging &amp;&amp; m_cursorInside)
      {
          m_figureSelected-&gt;Move(point);
          Invalidate();
      }
      ...
      CView::OnMouseMove(nFlags, point);
  }
  </code></pre>
  
  <p>This is my <code>OnDraw</code> function:</p>
  
  <pre><code>void CGraphicsEditorView::OnDraw(CDC* pDC)
  {
      for (Figure* figure : figures)
          figure-&gt;Draw(pDC);
  }
  </code></pre>
  
  <p>Figure is an abstract class from which are inherited Rectangle, Ellipse and Triangle classes.</p>
  
  <p>For example, <code>Draw</code> function for Rectangle:</p>
  
  <pre><code>void CRectangle::Draw(CDC* pDC) {
      pDC-&gt;SelectStockObject(NULL_BRUSH);
  
      CPen penBorder(penType, penWidth, borderColor);
      CBrush* br = (brushType == HS_TRANSPARENT) ? nullptr : new CBrush(brushType, fillColor);
      pDC-&gt;SelectObject(&amp;penBorder);
      pDC-&gt;SelectObject(br);
  
      pDC-&gt;Rectangle(bound);
  }
  </code></pre>
  
  <p>Do I redraw the window correctly?
  Thank you in advance for your help.</p>