Partilhar via


CDC::DeleteDC

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

BOOL DeleteDC( );

Return Value

Nonzero if the function completed successfully; otherwise 0.

Remarks

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.

Example

See the example for CPrintDialog::GetPrinterDC.

Requirements

Header: afxwin.h

See Also

Reference

CDC Class

Hierarchy Chart

CDC::CDC

DeleteDC

CDC::CreateDC

CDC::CreateIC

CDC::CreateCompatibleDC

CWnd::GetDC

CWnd::ReleaseDC

Other Resources

CDC Members