c++ creating animation help gdi and repaint window win32

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramilol
    New Member
    • Aug 2010
    • 14

    c++ creating animation help gdi and repaint window win32

    ok im trying to create a animation of circle i have a while loop that loops and set var value the varable will be used to set the circle x value
    here is the loop
    Code:
    while(sd==1)
    		{
    			sf++;//globe var, sf equals 1
    			onPaint(hdc);//paint the circle
    			InvalidateRect (hWnd, NULL, TRUE);//it should repaint the window but it doesn't
    			UpdateWindow(hWnd);
    		}
    well i can sucessfully draw the cirlce but not repaint it what happens is this it creates a circle with x value 1 than it creates another circle with value 3 it shouldn't it should delete the circle with value 2 than create new one with value 3
    here is the draw circle code
    Code:
    VOID onPaint(HDC hdc)
    {
       Graphics graphics(hdc);
       Pen      pen(Color(255, 0, 0, 255));
       graphics.DrawEllipse(&pen, sf , 0, 10, 10);
    }
    i posted this question in 2 different place still no answer would help me. i would really appreciation your help
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    You are right when you say "it should delete the circle with value 2". 'it' - is your program, the code of onPaint function. It should take care of erasing whatever garbage in the drawing context before it is called and draw what you need. It should not expect blank canvas.

    Comment

    • ramilol
      New Member
      • Aug 2010
      • 14

      #3
      how am i suppose to do that?

      Comment

      • newb16
        Contributor
        • Jul 2008
        • 687

        #4
        I'd search for gdi function that contains 'fill' in its name.

        Comment

        Working...