Compaq Visual Fortran: A Guide to Creating Windows Applications

So far, we have created memory devices that are compatible with the display screen, loaded bitmaps into the memory-compatible device, and used the BitBlt function to transfer the image to the screen or printer. However, we can also create our own bitmaps in memory. All we need to do is allocate an area in memory in which the image will be created. This block of memory becomes a memory bitmap using the function CreateCompatibleBitmap. The GDI allocates the memory and internal data structures for this bitmap object and supplies a handle to the bitmap. The memory bitmap is a GDI object, and it can be drawn on using GDI functions. However, since we are drawing on a bitmap in memory, we need to create a memory device context that is compatible with the display screen using the CreateCompatibleDC function so that we can ultimately view the image after it has been created. When you select the compatible bitmap into the compatible device context, you have effectively created an image area in memory that simulates the display screen. You can draw into it and perform any operation that you could perform on the actual screen.
At first that may not seem particularly useful, because you cannot view objects being drawn in memory in the same way as when they are drawn on the display screen. However, instead of displaying all the drawing steps on the screen as they occur during the creation of a complex drawing, an application can...