23.1 Using an Identity Palette

Windows reserves a group of system palette entries for a fixed number of colors. These colors, which are named system colors, are used for drawing screen elements such as scroll bars. Windows also uses the system colors as replacement color entries when inactive windows request more color entries than are available in the system palette. Windows places the system colors at the top and bottom of the system palette to ensure that logical operations (such as XOR) work correctly.

By arranging logical palettes the same way that Windows arranges the system palette, you can avoid unexpected color changes and improve the speed at which your application draws DIBs. To do this, you must create an identity palette, a logical palette that matches the system palette. To use identity palettes, however, you need to understand how Windows sets up the system palette.