Collapse the table of content
Expand the table of content



In general, do not call this function; the destructor will do it for you.

BOOL DeleteDC( );

Nonzero if the function completed successfully; otherwise 0.

The DeleteDC member function deletes the Windows device contexts that are associated with m_hDC in the current CDC object. If this CDC object is the last active device context for a given device, the device is notified and all storage and system resources used by the device are released.

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

An application must not delete a device context whose handle was obtained by calling CWnd::GetDC. Instead, it must call CWnd::ReleaseDC to free the device context. The CClientDC and CWindowDC classes are provided to wrap this functionality.

The DeleteDC function is generally used to delete device contexts created with CreateDC, CreateIC, or CreateCompatibleDC.


See the example for CPrintDialog::GetPrinterDC.


Header: afxwin.h

© 2016 Microsoft