2.1.4 Compatible Device Contexts

The CreateCompatibleDC function causes Windows to treat a portion of memory as a virtual device. This means that Windows prepares a device context that has the same attributes as the device for which it was created, but the device context has no connected output device. To use the compatible device context, the application creates a compatible bitmap and selects it into the device context. Any output it sends to the device is drawn in the selected bitmap. Since the de-vice context is compatible with some actual device, the context of the bitmap can be copied directly to the actual device, or vice versa. This also means that the application can send output to memory (prior to sending it to the device). Note that the CreateCompatibleDC function works only for devices that have BitBlt capabilities.