UINT GetSystemPaletteEntries(hdc, iStart, cEntries, lppe) | |||||
HDC hdc; | /* handle of device context | */ | |||
UINT iStart; | /* first palette entry to retrieve | */ | |||
UINT cEntries; | /* number of entries to retrieve | */ | |||
PALETTEENTRY FAR* lppe; | /* address of structure for palette entries | */ |
The GetSystemPaletteEntries function retrieves a range of palette entries from the system palette.
hdc
Identifies the device context.
iStart
Specifies the first system-palette entry to be retrieved.
cEntries
Specifies the number of system-palette entries to be retrieved.
lppe
Points to an array of PALETTEENTRY structures that receives the palette entries. The array must contain at least as many structures as specified by the cEntries parameter. The PALETTEENTRY structure has the following form:
typedef struct tagPALETTEENTRY { /* pe */
BYTE peRed;
BYTE peGreen;
BYTE peBlue;
BYTE peFlags;
} PALETTEENTRY;
For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.
The return value is the number of entries retrieved from the system palette, if the function is successful. Otherwise, it is zero.
The following example uses the GetDeviceCaps function to determine whether the specified device is palette-based. If the device supports palettes, the GetSystemPaletteEntries function is called, using GetDeviceCaps again, this time to determine the number of entries in the system palette.
PALETTEENTRY
pe[MAXNUMBER]; hdc = GetDC(hwnd); if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)) { ReleaseDC(hwnd, hdc); break; } GetSystemPaletteEntries(hdc, 0, GetDeviceCaps(hdc, SIZEPALETTE), pe); ReleaseDC(hwnd, hdc);