CreateCompatibleDC

  HDC CreateCompatibleDC(hdc)    
  HDC hdc;    

The CreateCompatibleDC function creates a memory device context that is compatible with the device specified by the hdc parameter.

An application must select a bitmap into a memory DC to represent a device surface. The DC may then be used to prepare images in memory before copying them to the actual device surface of the compatible device.

Parameters

hdc

Identifies the device context. If hdc is 0, the function creates a memory device context that is compatible with the application's active display.

Return Value

The return value identifies the new memory device context if the function is successful. Otherwise, it is 0.

Comments

This function can only be used to create compatible device contexts for devices that support raster operations. For more information, see the RC_BITBLT raster capability in the GetDeviceCaps function, later in this chapter.

GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.

When the application no longer requires the device context, it should free it by calling the DeleteDC function.

See Also

CreateCompatibleBitmap, DeleteDC, GetDeviceCaps