title: OnPaint is updated too often
body: <p>I have a problem with the OnPaint method of CFrameWnd, and I cant seem to figure out what is happening. OnPaint is called approx every 10 ms, which causes the computer to freeze. Checked CPU usage and this app takes up 50%!</p>
  
  <p>The application is a very simple MFC app, which is written in one file.</p>
  
  <pre><code>// Includes are done here...
  
  class MFC_Tutorial_Window : public CFrameWnd
  {
  std::string data;
  
  public:
      MFC_Tutorial_Window()
      {
           this-&gt;data = "";
           Create(NULL, "Data Win");  // Create window
      }
  
      void OnPaint()
      {   
          CDC* pDC = GetDC();
  
          CString s = CString(this-&gt;data.c_str());
          RECT rc;
  
          HWND hwnd = this-&gt;m_hWnd;
          if(hwnd != NULL) {
              ::GetWindowRect(hwnd, &amp;rc);
  
              rc.top = rc.bottom/2;
  
              if(pDC != NULL &amp;&amp; pDC-&gt;m_hDC != NULL) {
                  pDC-&gt;DrawText(s, &amp;rc, DT_CENTER);
              }
          }
      }
  
      void UpdateWithNewData(std::string up) {
          this-&gt;data = up;
          Invalidate();
      }
  
  
      DECLARE_MESSAGE_MAP()
  };
  
  BEGIN_MESSAGE_MAP(MFC_Tutorial_Window, CFrameWnd)
      ON_WM_PAINT()       
  END_MESSAGE_MAP()
  
  // App class
  class MyApp :public CWinApp
  {
      MFC_Tutorial_Window *wnd;
  
      BOOL InitInstance()
      {
          wnd = new MFC_Tutorial_Window();
          m_pMainWnd = wnd;
          m_pMainWnd-&gt;ShowWindow(3);
  
                         wnd-&gt;UpdateWithNewData("Hello world!");          
               return 1;
      }
  };
  </code></pre>
  
  <p>Does anyone know why OnPaint is spammed by the system? Have been staring at this code for ages and I just can't find it.</p>