When processing the drawing process in VC, if the graphics refresh quickly, the phenomenon of graphics flicker often occurs. Using the method of first drawing in memory and then copying to the screen can eliminate the flicker of the screen by first creating a device-compatible memory device context in memory, i.e. opening up a fast memory area as the display area and then drawing the graphics in this memory area. Use the BitBlt function to copy the graphics of the memory directly onto the screen after the drawing is complete.
What you want to do is to draw a few dynamic points in a picture control (IDC_MAP) in the dialog client area, which flashes when the screen refreshes without a double-buffering technique.
CRect rect; cwnd* pWnd = GetDlgItem (Idc_map); Pwnd->getwindowrect (&rect); Gets the control screen coordinates pwnd->screentoclient (&rect); Convert to the corresponding control coordinate cdc* PDC = PWND->GETDC (); cdc* Pmem =new CDC; Defines the device context for a memory drawing cbitmap* pBmp = new CBitmap; cbitmap* poldbmp;//cdc* dc=getdc ();p Mem->createcompatibledc (PDC);p Bmp->createcompatiblebitmap (pDC,rect. Width (), Rect. Height ());p oldbmp = Pmem->selectobject (PBMP); Drawing in Pmem ...//The location of the drawing in memory is copied to display in the control Pdc->bitblt (Rect.left,rect.top,rect. Width (), Rect. Height (), pmem,0,0,srccopy);p mem->selectobject (poldbmp);p bmp->deleteobject ();p Mem->deletedc ();
The effect of the implementation is as follows:
In the OnTimer to achieve the target point of movement, click the button matching point to complete the line, start the timer again, re-draw the location information, to achieve dynamic real-time display information.
MFC refreshes the drawing with double buffering