Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


The wglSetLayerPaletteEntries function sets the palette entries in a given color-index layer plane for a specified device context.

int wglSetLayerPaletteEntries(
  HDC  hdc,          // device context whose layer palette is to be 
                     // set
  int  iLayerPlane,  // specifies an overlay or underlay plane
  int  iStart,       // specifies the first palette entry to be set
  int  cEntries,     // specifies the number of palette entries to 
                     // be set
 // points to the first member of an array of 
                     // COLORREF structures


Specifies the device context of a window whose layer palette is to be set.
Specifies an overlay or underlay plane. Positive values of iLayerPlane identify overlay planes, where 1 is the first overlay plane over the main plane, 2 is the second overlay plane over the first overlay plane, and so on. Negative values identify underlay planes, where 1 is the first underlay plane under the main plane, 2 is the second underlay plane under the first underlay plane, and so on. The number of overlay and underlay planes is given in the bReserved member of the PIXELFORMATDESCRIPTOR structure.
Specifies the first palette entry to be set.
Specifies the number of palette entries to be set.
Points to the first member of an array of cEntries COLORREF structures that contain RGB color information.

Return Values

If the function succeeds, the return value is the number of entries that were set in the palette in the specified layer plane of the window. If the function fails or no pixel format is selected, the return value is zero. To get extended error information, call GetLastError.


Each color-index plane in a window has a palette with a size 2^n, where n is the number of bit planes in the layer plane. You cannot modify the transparent index of a palette.

Use the wglRealizeLayerPalette function to realize the layer palette. Initially the layer palette contains only entries for white.

The wglSetLayerPaletteEntries function doesn't set the palette entries of the main plane palette. To update the main plane palette, use GDI palette functions.


  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in wingdi.h.
  Import Library: Use opengl32.lib.

See Also

OpenGL on Windows NT, Windows 2000, and Windows 95/98, WGL Functions, LAYERPLANEDESCRIPTOR, PIXELFORMATDESCRIPTOR, wglDescribeLayerPlane, wglGetLayerPaletteEntries, wglRealizeLayerPalette


Community Additions

© 2015 Microsoft