Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDXGISurface1::GetDC method

Returns a device context (DC) that allows you to render to a Microsoft DirectX Graphics Infrastructure (DXGI) surface using Windows Graphics Device Interface (GDI).

Syntax


HRESULT GetDC(
  [in]   BOOL Discard,
  [out]  HDC *phdc
);

Parameters

Discard [in]

Type: BOOL

A Boolean value that specifies whether to preserve Direct3D contents in the GDI DC. TRUE directs the runtime not to preserve Direct3D contents in the GDI DC; that is, the runtime discards the Direct3D contents. FALSE guarantees that Direct3D contents are available in the GDI DC.

phdc [out]

Type: HDC*

A pointer to an HDC handle that represents the current device context for GDI rendering.

Return value

Type: HRESULT

Returns S_OK if successful; otherwise, an error code.

Remarks

This method is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2 (SP2) (KB 971644) and Windows Server 2008 (KB 971512).

After you use the GetDC method to retrieve a DC, you can render to the DXGI surface by using GDI. The GetDC method readies the surface for GDI rendering and allows inter-operation between DXGI and GDI technologies.

Keep the following in mind when using this method:

You can also call GetDC on the back buffer at index 0 of a swap chain by obtaining an IDXGISurface1 from the swap chain. The following code illustrates the process.



IDXGISwapChain* g_pSwapChain = NULL;
IDXGISurface1* g_pSurface1 = NULL;
...
//Setup the device and and swapchain
g_pSwapChain->GetBuffer(0, __uuidof(IDXGISurface1), (void**) &g_pSurface1);
g_pSurface1->GetDC( FALSE, &g_hDC );
...      
//Draw on the DC using GDI
...
//When finish drawing release the DC
g_pSurface1->ReleaseDC( NULL );
      

Requirements

Minimum supported client

Windows 7 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2 [desktop apps | Windows Store apps]

Header

DXGI.h

Library

DXGI.lib

See also

DXGI Interfaces
IDXGISurface1

 

 

Community Additions

Show:
© 2014 Microsoft