AnimatePalette

3.0

  void AnimatePalette(hpal, iStart, cEntries, lppe)    
  HPALETTE hpal; /* handle of palette, */  
  UINT iStart; /* first palette entry to animate */
  UINT cEntries; /* number of entries in palette */
  const PALETTEENTRY FAR* lppe; /* address of color structure */

The AnimatePalette function replaces entries in the specified logical palette. An application does not have to update the client area when it calls AnimatePalette, because Windows maps the new entries into the system palette immediately.

Parameters

hpal

Identifies the logical palette.

iStart

Specifies the first entry in the palette to be animated.

cEntries

Specifies the number of entries in the palette to be animated.

lppe

Points to the first member of an array of PALETTEENTRY structures. These palette entries will replace the palette entries identified by the iStart and cEntries parameters. 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.

Return Value

This function does not return a value.

Comments

The AnimatePalette function can change an entry in a logical palette only when the PC_RESERVED flag is set in the corresponding palPaletteEntry member of the LOGPALETTE structure that defines the current logical palette.

Example

The following example initializes a LOGPALETTE structure and an array of PALETTEENTRY structures, uses the CreatePalette function to retrieve a handle of a logical palette, and then uses the AnimatePalette function to map the entries into the system palette:

#define NUMENTRIES 128
HPALETTE hpal;
PALETTEENTRY ape[NUMENTRIES];

plgpl = (LOGPALETTE*) LocalAlloc(LPTR,
    sizeof(LOGPALETTE) + cColors * sizeof(PALETTEENTRY));

plgpl->palNumEntries = cColors;
plgpl->palVersion = 0x300;





for (i = 0, red = 0, green = 127, blue = 127; i < NUMENTRIES;
        i++, red += 1, green += 1, blue += 1) {
    ape[i].peRed =
        plgpl->palPalEntry[i].peRed = LOBYTE(red);
    ape[i].peGreen =
        plgpl->palPalEntry[i].peGreen = LOBYTE(green);
    ape[i].peBlue =
        plgpl->palPalEntry[i].peBlue = LOBYTE(blue);
    ape[i].peFlags =
        plgpl->palPalEntry[i].peFlags = PC_RESERVED;
}
hpal = CreatePalette(plgpl);
LocalFree((HLOCAL) plgpl);
AnimatePalette(hpal, 0, NUMENTRIES, (PALETTEENTRY FAR*) &ape);

See Also

CreatePalette