GpiSelectPalette

This function selects a palette into a presentation space.

Syntax
GpiSelectPalette(hps, hpal)

Parameters

 * hps (HPS) - input:Presentation-space handle.
 * hpal (HPAL) - input:Palette handle.
 * NULLHANDLE : Set the color table for the presentation space to the default table (see GpiCreateLogColorTable).
 * Other : Palette handle.

Returns

 * hpalOld (HPAL) - returns:Old palette handle.
 * NULLHANDLE :Successful completion, default (or loaded) color table was in effect
 * PAL_ERROR :Error occurred
 * Otherwise :Old palette handle.

Errors
Possible returns from WinGetLastError:
 * PMERR_INV_HPS (0x207F):An invalid presentation-space handle was specified.
 * PMERR_PS_BUSY (0x20F4):An attempt was made to access the presentation space from more than one thread simultaneously.
 * PMERR_INV_HPAL (0x2111):An invalid color palette handle was specified.
 * PMERR_INSUFFICIENT_MEMORY (0x203E):The operation terminated through insufficient memory.
 * PMERR_PALETTE_BUSY (0x2112):An attempt has been made to reset the owner of a palette when it was busy.
 * PMERR_INV_IN_AREA (0x2085):An attempt was made to issue a function invalid inside an area bracket. This can be detected while the actual drawing mode is draw or draw-and-retain or during segment drawing or correlation functions.

Example Source Code
This function selects a palette into a presentation space. 
 * 1) define INCL_GPILOGCOLORTABLE
 * 2) include 

HPS hps;      /* presentation-space handle. */ HPAL hpalOld, hpal; /* old palette handle. */ hpalOld = GpiSelectPalette(hps, hpal); 

Remarks
This function overrides any color table previously loaded (see GpiCreateLogColorTable), or palette previously selected into this presentation space.

If hpal is specified as NULLHANDLE, then the color table for this presentation space is set to the default color table.

Palettes can be selected into more than one presentation space at a time, but only one palette can be selected into a given presentation space at any time.

If a palette is selected into a presentation space that is associated with a device context of type OD_MEMORY (see DevOpenDC in the Presentation Manager Programming Reference) irreversible changes take place to any bit map selected into the device context.

If a palette is selected into a presentation space that is associated with a device context of type OD_METAFILE or OD_METAFILE_NOQUERY the palette must apply to the entire picture, and must still be selected at the (last) time the metafile device context is dissociated from the presentation space.

Related Functions

 * GpiAnimatePalette
 * GpiCreateLogColorTable
 * GpiCreatePalette
 * GpiDeletePalette
 * GpiQueryPalette
 * GpiQueryPaletteInfo
 * GpiSetPaletteEntries