When an application realizes a palette (that is, requests the palette be given specified colors), Windows adds the logical palette entries to the system pal-ette. Windows always reserves system palette entries for the system colors. For example, a 256-color video graphics adapter (VGA) driver with 20 system colors allows an application to use a maximum of 236 system palette entries. If a logical palette contains more entries than can fit in the system palette (after the system colors are added), Windows truncates the palette, using only as many colors as it can fit without encroaching on the reserved system colors. You can force Windows to relinquish the system color entries (by using the SetSystemPaletteUse function), but by doing so you change the coloring of all Windows screen elements to black and white.
The maximum number of colors available to a foreground window equals the number of colors supported by the video driver minus the number of system reserved colors and the number of palette entries reserved by the application.
Windows places the system colors at the top and bottom of the system palette. For example, a 256-color VGA driver uses the top 10 and bottom 10 system palette entries for the system colors. If a logical palette does not contain the system colors or if the system colors appear in locations other than the default positions,
Windows changes the ordering of the palette entries when your application realizes its palette. At this point, logical palette entry n does not necessarily match system palette entry n. When your application draws a bitmap to the device context, Windows must translate the bitmap palette indices to the new locations on the system palette. This translation step takes time.
The goal is to make the logical palette exactly match the system palette. By doing so, your images can be colored exactly as you expect. The video driver can also draw the images faster because the translation step is avoided.