To create a logical palette, you should assign values to the members of a LOGPALETTE structure and pass a pointer to the structure to the CreatePalette function. The function returns a handle to a logical palette with the values specified in the LOGPALETE structure.
To gain access to the colors in the logical palette, use the SelectPalette function to select the palette into the current device context, and then use the RealizePalette function to make the system palette the same as the palette in the current device context. You can use the colors in the palette as soon as the logical palette has been realized.
Caution The GetSystemPaletteEntries and RealizePalette functions will fail if the device associated with the selected device index does not have a settable palette. You can use GetDeviceCaps to find out if the device has a settable palette.
Your logical palette should have just enough entries to represent the colors you need. You can use the GetDeviceCaps function to retrieve the maximum palette size associated with a device, or the SIZEPALETTE member.
You can use the SetPaletteEntries function to change the colors in an existing logical palette. After you have updated the colors, use RealizePalette to update the display. If you select a logical palette into more than one device context, any changes you make to the logical palette will affect all the device contexts to which it is attached.
You can use the GetPaletteEntries function to retrieve the color values for a logical palette. Use the GetNearestPaletteIndex function to retrieve the value in a specified logical palette that most closely matches a specified color value.
Use the DeleteObject function to delete a logical palette. Be sure that the logical palette is not selected into a device context when you delete it.
Windows CE does not arbitrate between the palettes of the background and foreground applications. The application running in the foreground has complete control over the system palette. Because of this, you should generally use only the first ten and last ten colors included in the stock palette of a display device, which are generally the standard Windows/VGA colors. Applications that use other colors may not display properly when they run in the background. Because Windows CE does not perform any color matching operations between the foreground and background applications, background applications cannot call RealizePalette.