SelectPalette

  HPALETTE SelectPalette(hdc, hpal, bForceBackground)    
  HDC hdc; /* handle of device context */
  HPALETTE hpal; /* handle of logical color-palette */
  BOOL bForceBackground; /* foreground/background mode */

The SelectPalette function selects the given logical-palette into the given device-context.

Parameters

hdc

Identifies the device context.

hpal

Identifies the logical palette to be selected.

bForceBackground

Specifies whether the logical palette is forced to be a background palette. If this value is TRUE, then RealizePalette will cause the logical palette to be mapped to the colors already in the physical palette in the best way possible. This is always done, even if the window for which the palette is realized belongs to a thread without active focus.

If this value is FALSE, then RealizePalette will cause the logical palette to be copied into the device palette when the application is in the foreground. (If hdc is a memory DC, this parameter is ignored.)

Return Value

The return value identifies the device-context's previous logical-palette if the function is successful. Otherwise it is 0.

Comments

An application can select a logical palette into more than one device context. However, changes to a logical palette will affect all device contexts for which it is selected.

An example where an application might call the SelectPalette function with bForceBackground set to TRUE is a top-level window whose child windows each realize their own palettes. In such cases, only the child window that needs to realize its palette should set bForceBackground to TRUE; other child windows should set this value to FALSE.

See Also

CreatePalette, RealizePalette