ID2D1DCRenderTarget::BindDC 方法 (d2d1.h)

將轉譯目標系結至發出繪圖命令的裝置內容。

語法

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

參數

hDC

類型: const HDC

轉譯目標發出繪圖命令的裝置內容。

[in] pSubRect

類型:const RECT*

轉譯目標所系結之裝置內容的控制碼維度 (HDC) 。

傳回值

類型: HRESULT

如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。

備註

您必須先使用其 BindDC 方法來將它與 GDI DC 產生關聯,才能使用 DC 轉譯目標進行轉譯。 每次使用不同的 DC,或您想要繪製到變更的區域大小時,您都會這麼做。

範例

在上述程式碼 中,m_pD2DFactoryID2D1Factory的指標, 而 m_pDCRTID2D1DCRenderTarget的指標。

下一個程式碼範例會將 DC 系結至 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);

規格需求

   
最低支援的用戶端 適用于 Windows Vista 的 Windows 7、Windows Vista SP2 和平臺更新 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 d2d1.h
程式庫 D2d1.lib
Dll D2d1.dll

另請參閱

Direct2D 和 GDI 交互操作概觀

ID2D1DCRenderTarget