title: MFC OnDraw vs. OnPaint
body: <p>I am wondering about the difference between <code>OnDraw()</code> and <code>OnPaint()</code> in MFC.</p>
  <p>After searching the Internet for a while, I found a useful <a href="https://forums.codeguru.com/showthread.php?327604-RESOLVED-OnDraw()-vs-OnPaint()" rel="nofollow noreferrer">article</a>. In summary,</p>
  <ol>
  <li><p><code>WM_PAINT</code> will trigger <code>OnPaint()</code>, which calls <code>OnDraw()</code> and passes a <code>CDC*</code>:</p>
  <pre class="lang-cpp prettyprint-override"><code>void CView::OnPaint()
  {
      // standard paint routine
      CPaintDC dc(this);
      OnPrepareDC(&amp;dc);
      OnDraw(&amp;dc);
  }
  </code></pre>
  </li>
  <li><p>Another <a href="http://computer-programming-forum.com/82-mfc/c54806a1479b95b0.htm" rel="nofollow noreferrer">article</a> mentions that when printing a document, <code>OnPrint()</code> also calls <code>OnDraw()</code> by passing a printer DC.  Therefore, by overriding <code>OnDraw()</code>, you get screen painting and printing both in one function, which is convenient.</p>
  </li>
  </ol>
  <p>I tried to put my statements for drawing in either <code>OnDraw()</code> and <code>OnPaint()</code>. Either can work well. <code>OnDraw()</code> is a little easier because it has already gotten a pointer <code>pDC</code>.</p>