> 怎么我用了sleep后,只会显示最后一张GDI may cache the drawing. To flush caching, call GetPixel after each drawing call.But the right method is to use either a thread or timer message. You can redraw outside of WM_PAINT message handling. For example:CView::OnTimer() { if (m_CurrentFrame < m_MaxFrame) { HDC hDC = GetDC(m_hWnd); // draw frame m_CurrentFrame ReleaseDC(m_hWnd, hDC); } else { m_CurrentFrame ++; } }
另外,在定时器中保存当前的现实位置,在OnDraw中重绘,效果较好。
{
if (m_CurrentFrame < m_MaxFrame)
{
HDC hDC = GetDC(m_hWnd);
// draw frame m_CurrentFrame
ReleaseDC(m_hWnd, hDC);
}
else
{
m_CurrentFrame ++;
}
}