There are many articles on the web about how to use Visual C + + programs to achieve double buffering, are written in C + + object-oriented language, it may be difficult for many C-language beginners who have not touched the object-oriented language, and some kind of people just paste the source code up, do not comment, This makes the reader more laborious to read.
Here, I will explain each statement. One of the places is more interesting and worth discussing (see below). Well, let's start by looking at the basic principle of double buffering:
First, double buffering principle and diagram
(1) Defines the device description table and the bitmap handle
hdc HMEMDC;
hbitmap Hbitmap;
(2) Create a memory Display device Description table compatible with the window rectangle display, 1 steps
    HMEMDC = CreateCompatibleDC (HDC);
(3) Create a bitmap with HDC that is compatible with the window rectangle display, 2 steps
hbitmap = CreateCompatibleBitmap (hdc, Rt.right-rt.left, Rt.bottom-rt.top);//rt is a rect variable, the value is the window rectangle
(4) to select the bitmap hbitmap into the memory display device Hdcmem, only the memory display device with the bitmap selected has a local drawing, draws to the specified bitmap, 3 steps
selectobject (HMEMDC, HBITMAP);
(5) Clear the bitmap with the HDC background color, 4 steps
fillrect (Hdcmem, &rt, Hbrush)
(6) Drawing, 5 steps
drawcircle (&hdcmem, RT, RADIUS)
( This step is actually to draw all the pictures you need to draw on the HMEMDC device, and then copy it to HDC)
(7) copies the in-Memory diagram to the window rectangle for display, 6 steps
  bitblt (hdc, 0, 0, Rt.right-rt.left, rt.bottom-rt.top, Hdcmem, 0, 0, SRCCOPY) /span>