DeleteDC

2.x

  BOOL DeleteDC(hdc)    
  HDC hdc; /* handle of device context */

The DeleteDC function deletes the given device context.

Parameters

hdc

Identifies the device context.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

If the hdc parameter identifies the last device context for a given device, the
device is notified and all storage and system resources used by the device are
released.

An application must not delete a device context whose handle was retrieved by calling the GetDC function. Instead, the application must call the ReleaseDC function to free the device context.

An application should not call DeleteDC if the application has selected objects into the device context. Objects must be selected out of the device context before it is deleted.

Example

The following example uses the CreateDC function to create a device context for a printer and then calls the DeleteDC function when the device context is no longer needed:

/* Retrieves a device context for a printer. */

hdcPrinter = CreateDC(lpDriverName, lpDeviceName, lpOutput,
    lpInitData);
    .
    . /* Use the device context. */
    .

/* Delete the device context. */

DeleteDC(hdcPrinter);

See Also

CreateDC, GetDC, ReleaseDC