Hi
I am attempting to create a simple program to bounce a ball around the screen. I have got the ball moving around the screen but with flicker.
My OnDraw function looks like this:
void CBallAnimView::OnDraw(CDC* pDC)
{
CBallAnimDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// remove the old ball
pDC->FillSolidRect(x, y, r, r, RGB(255, 255, 255));
// calculate the position of the new ball
x = pDoc->m_ball.pPosition.x;
y = pDoc->m_ball.pPosition.y;
r = pDoc->m_ball.nRadius * 2;
// draw the new ball
pDC->BitBlt(x, y, r, r, &pDoc->m_ball.pBallDC, 0, 0, SRCCOPY);
}
I have a timer which is calling InvalidateRect(...). The rectangle passed to InvalidateRect includes the old ball so it can be removed and the new ball so it can be drawn.
Does anyone have any ideas on how to remove the flicker?
Thank you.
I am attempting to create a simple program to bounce a ball around the screen. I have got the ball moving around the screen but with flicker.
My OnDraw function looks like this:
void CBallAnimView::OnDraw(CDC* pDC)
{
CBallAnimDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// remove the old ball
pDC->FillSolidRect(x, y, r, r, RGB(255, 255, 255));
// calculate the position of the new ball
x = pDoc->m_ball.pPosition.x;
y = pDoc->m_ball.pPosition.y;
r = pDoc->m_ball.nRadius * 2;
// draw the new ball
pDC->BitBlt(x, y, r, r, &pDoc->m_ball.pBallDC, 0, 0, SRCCOPY);
}
I have a timer which is calling InvalidateRect(...). The rectangle passed to InvalidateRect includes the old ball so it can be removed and the new ball so it can be drawn.
Does anyone have any ideas on how to remove the flicker?
Thank you.