To put it simply, the basic concept is to set a memory for temporarily storing graphic information, put all the temporary drawing content in the saved CDC, and then call it after all the items are put in it.
Implementation steps
1. First, define a temporary device context
Cdch_bufdc; // two-buffer layer cbitmapmembitmap; // define a bitmap object
2. initialize it.
CDC * PDC = getdc (); h_bufdc.createcompatibledc (PDC); membitmap. createcompatiblebitmap (PDC, screen_w, screen_h); SelectObject (h_bufdc, membitmap); h_bufdc.fillsolidrect (0, 0, screen_w, screen_h, RGB (255,255,255 ));
3. Operation
//
Other operations such as drawing can be put into h_bufdc in the middle.
//
4. Use the display function.
CDC * PDC = getdc (); // obtain the context of the display device for the final display of PDC-> bitblt (0, 0, screen_w, screen_h, & h_bufdc, 0, 0, 0, srccopy); // copy the saved content to the context of the display device for display.
5. Finally release
Membitmap. deleteobject (); // Delete the bitmap object h_bufdc.deletedc (); // Delete the buffer DC