title: How to repaint in CDC::OnDraw()?
body: <p>I want to update the window (Delete the previous drawing) and redraw using the new values of x2,y2. I get x2 and y2 from a camera and they are hand coordinates, I want to draw the ellipse based on new values of the hand coordinates. How can i do that?</p>
  
  <p>I tried to call Invalidate(), RedrawWindow() and UpdateWindow(), but none of them seem to work. Following is a chunk of my code.</p>
  
  <pre><code>     int x2,y2 // Global Variables (used to store coordinates of the hand)
       void GesturePipe()
        {
           x2=Hand.Coordinate.x;
           y2=Hand.Coordinate.y;
  
           // I get x2,y2 from a camera
        }
  
  
       void CLesson1View::OnDraw(CDC* pDC)
       {
      while(1)
        {
          GesturePipe();
          CLesson1Doc* pDoc = GetDocument();
          ASSERT_VALID(pDoc);
          if (!pDoc)
      return;
          COLORREF colorCircle= RGB(255,0,0); 
          pDC-&gt;Ellipse(0,0,(int) x2,(int) y2);
         //I intend to draw the skeleton of the hands so i would draw five lines,which  will get updated with each frame
          Invalidate(TRUE);
          UpdateWindow();
  
  }
  </code></pre>
  
  <p>}</p>