D2D1_HWND_RENDER_TARGET_PROPERTIES structure (d2d1.h)

Contains the HWND, pixel size, and presentation options for an ID2D1HwndRenderTarget.

Syntax

typedef struct D2D1_HWND_RENDER_TARGET_PROPERTIES {
  HWND                 hwnd;
  D2D1_SIZE_U          pixelSize;
  D2D1_PRESENT_OPTIONS presentOptions;
} D2D1_HWND_RENDER_TARGET_PROPERTIES;

Members

hwnd

Type: HWND

The HWND to which the render target issues the output from its drawing commands.

pixelSize

Type: D2D1_SIZE_U

The size of the render target, in pixels.

presentOptions

Type: D2D1_PRESENT_OPTIONS

A value that specifies whether the render target retains the frame after it is presented and whether the render target waits for the device to refresh before presenting.

Remarks

Use this structure when you call the CreateHwndRenderTarget method to create a new ID2D1HwndRenderTarget.

For convenience, Direct2D provides the D2D1::HwndRenderTargetProperties function for creating new D2D1_HWND_RENDER_TARGET_PROPERTIES structures.

Examples

The following example uses the CreateHwndRenderTarget method to create an ID2D1HwndRenderTarget. It uses the D2D1::HwndRenderTargetProperties helper function to create a D2D1_HWND_RENDER_TARGET_PROPERTIES structure that contains a handle to a window and the size of the drawing area. Because a D2D1_PRESENT_OPTIONS value isn't specified, the function uses the default value, D2D1_PRESENT_OPTIONS_NONE.

RECT rc;
GetClientRect(m_hwnd, &rc);

D2D1_SIZE_U size = D2D1::SizeU(
    rc.right - rc.left,
    rc.bottom - rc.top
    );

// Create a Direct2D render target.
hr = m_pD2DFactory->CreateHwndRenderTarget(
    D2D1::RenderTargetProperties(),
    D2D1::HwndRenderTargetProperties(m_hwnd, size),
    &m_pRenderTarget
    );

Code has been omitted from this example.

Requirements

Requirement Value
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]
Header d2d1.h

See also

ID2D1HwndRenderTarget