ID2D1DCRenderTarget::BindDC method (d2d1.h)

Binds the render target to the device context to which it issues drawing commands.

Syntax

HRESULT BindDC(
       const HDC  hDC,
  [in] const RECT *pSubRect
);

Parameters

hDC

Type: const HDC

The device context to which the render target issues drawing commands.

[in] pSubRect

Type: const RECT*

The dimensions of the handle to a device context (HDC) to which the render target is bound.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Before you can render with the DC render target, you must use its BindDC method to associate it with a GDI DC. You do this each time you use a different DC, or the size of the area you want to draw to changes.

Examples

In the preceding code, m_pD2DFactory is a pointer to an ID2D1Factory, and m_pDCRT is a pointer to an ID2D1DCRenderTarget.

The next code example binds a DC to the ID2D1DCRenderTarget.

HRESULT DemoApp::OnRender(const PAINTSTRUCT &ps)
{

// Get the dimensions of the client drawing area.
GetClientRect(m_hwnd, &rc);

// Bind the DC to the DC render target.
hr = m_pDCRT->BindDC(ps.hdc, &rc);

Requirements

   
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header d2d1.h
Library D2d1.lib
DLL D2d1.dll

See also

Direct2D and GDI Interoperation Overview

ID2D1DCRenderTarget