ReleaseDC function

The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs.

Syntax

int ReleaseDC(
  HWND hWnd,
  HDC  hDC
);

Parameters

hWnd

A handle to the window whose DC is to be released.

hDC

A handle to the DC to be released.

Return Value

The return value indicates whether the DC was released. If the DC was released, the return value is 1.

If the DC was not released, the return value is zero.

Remarks

The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common DC.

An application cannot use the ReleaseDC function to release a DC that was created by calling the CreateDC function; instead, it must use the DeleteDC function. ReleaseDC must be called from the same thread that called GetDC.

Examples

For an example, see Scaling an Image.

Requirements

   
Windows version Windows 2000 Professional [desktop apps only] Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See Also

CreateDC

DeleteDC

Device Context Functions

Device Contexts Overview

GetDC

GetWindowDC