Current location - Education and Training Encyclopedia - Educational Knowledge - On the flicker of MFC painting
On the flicker of MFC painting
Using timer and DC drawing to do animation is not reliable. Yours is simple, but not complicated. Otherwise, there won't be anything like OpenGl, and many animation effects and 3D effects even need GPU.

SetTimer( 1, 10,0); //General animation needs 1/20 seconds continuously (20 frames per second), that is, a timer of 50 milliseconds, which is not as short as 10 milliseconds.

The simplest optimization method: in OnTimer, calculate two points, xunhuan and xunhuan- 1, to form a RECT, and use InvalidateRect instead of Invalidate realize partial redrawing, and the effect is basically tolerable.

Double buffering can optimize your program well. The process is a bit complicated. For the memDC of dialog box member variables, OnPaint created a compatible DC for the first time, OnTimer added a set of lines (MoveTo+LineTo), and OnPaint only needed BitBlt.