title: dc.LineTo not drawing on OnPaint() unless I move the use the mouse and move the window out of view?
body: <p>Unless I make  "static CPaintDC dc(this);" the line won't draw?  But this is not good as it will eventually error, also the graphics wont' keep on the screen.</p>
  
  <p>Not sure what I am doing wrong </p>
  
  <p>Note:  I have a Timer that calls to this every 100ms(x and y are incremented)
  thx</p>
  
  <pre><code>void CGraphicsDlg::OnPaint() 
  {
      CString s;
      CPaintDC dc(this);// device context for painting
  
      if (IsIconic())
      {
          SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  
          // Center icon in client rectangle
          int cxIcon = GetSystemMetrics(SM_CXICON);
          int cyIcon = GetSystemMetrics(SM_CYICON);
          CRect rect;
          GetClientRect(&amp;rect);
          int x = (rect.Width() - cxIcon + 1) / 2;
          int y = (rect.Height() - cyIcon + 1) / 2;
  
          // Draw the icon
          dc.DrawIcon(x, y, m_hIcon);
      }
      else if(x==0)
      {
          s.Format("%d", x);
          edXa-&gt;SetWindowText(s);
  
          dc.MoveTo(20,400);
      }
      else if (x&gt;0){
          s.Format("%d", x);
          edXb-&gt;SetWindowText(s);
  
          dc.LineTo(20 + x, 40);  // doesn't draw unless I make "static CPaintDC dc(this);" &lt;- which will error out 
      }
      CDialog::OnPaint();
  }
  
  void CGraphicsDlg::OnTimer(UINT nIDEvent)
  {
      if(nIDEvent==1){
          srand( (unsigned)time( NULL ) );
  
          //y = rand() % 100;
          y++;
          x++;
  
          OnPaint();
      }
  }
  </code></pre>