When the drawing process is performed in the VC, the phenomenon of graphic flicker often occurs if the graphics are refreshed quickly. Use the first to draw in memory, then copy to the screen, you can eliminate the screen flashes, the specific method is to create a memory device compatible with the device in memory, which is to open up a fast memory area as a display area, then in this The memory area is drawn. After the decoration is completed, use the Bitblt function to copy the memory graphics directly to the screen. The specific code is implemented as:
(1) Create a memory region CDC * pMem = new CDC; CBitmap * pBmp = new CBitmap; CBitmap * pOldBmp; CDC * pDC = GetDC (); CRect rectTemp; of the drawing area pMem-> CreateCompatibleDC (pDC); pBmp-> CreateCompatibleBitmap (PDC, RectTemp.width (), RectTemp.Height ()); PoldBMP = PMEM-> SelectObject (PBMP); (2) Graphics Draw PMEM-> LINETO (...); Drawing Processing (3) Copy to screen
PDC-> Bitblt (RectTemp.left, RectTemp.top, RectTemp.width (), RectTemp.Height (), PMEM, 0, 0, Srccopy; PMEM-> SelectObject (PBMP-> deleteObject (); PMEM -> deletedc ();