GetPixelFormat

The GetPixelFormat function obtains the index of the currently selected pixel format of the specified device context.

int GetPixelFormat(
  HDC  hdc  // device context whose currently selected pixel format 
            // index is sought
);
 

Parameters

hdc
Specifies the device context of the currently selected pixel format index returned by the function.

Return Values

If the function succeeds, the return value is the currently selected pixel format index of the specified device context. This is a positive, one-based index value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The following code sample shows GetPixelFormat usage:


PIXELFORMATDESCRIPTOR  pfd;
HDC  hdc;
int  iPixelFormat;
 
// get the current pixel format index 
iPixelFormat = GetPixelFormat(hdc); 
 
// obtain a detailed description of that pixel format 
DescribePixelFormat(hdc, iPixelFormat, 
        sizeof(PIXELFORMATDESCRIPTOR), &pfd); 
 

QuickInfo

  Windows NT: Use version 3.5 and later.
  Windows: Use Windows 95 and later.
  Windows CE: Unsupported.
  Header: Declared in wingdi.h.
  Import Library: Link with gdi32.lib.

See Also

OpenGL on Windows NT and Windows 95 Overview, Win32 Functions, ChoosePixelFormat, DescribePixelFormat, SetPixelFormat