UINT RealizePalette(hdc) | |||||
HDC hdc; | /* handle of device context | */ |
The RealizePalette function maps palette entries from the current logical palette to the system palette.
hdc
Identifies the device context containing a logical palette.
The return value indicates how many entries in the logical palette were mapped to different entries in the system palette. This represents the number of entries that this function remapped to accommodate changes in the system palette since the logical palette was last realized.
A logical color palette acts as a buffer between color-intensive applications and the system, allowing an application to use as many colors as necessary without interfering with either its own displayed color or with colors displayed by other windows. When a window has the input focus and calls the RealizePalette function, Windows ensures that the window will display all the requested colors (up to the maximum number simultaneously available on the screen) and Windows displays additional colors by matching them to available colors. In addition, Windows matches the colors requested by inactive windows that call RealizePalette as closely as possible to the available colors. This significantly reduces undesirable changes in the colors displayed in inactive windows.
The following example uses the SelectPalette function to select a palette into a device context and then calls the RealizePalette function to map the colors to the system palette:
HPALETTE hpal, hPalPrevious;
hdc = GetDC(hwnd);
hPalPrevious = SelectPalette(hdc, hpal, FALSE);
if (RealizePalette(hdc) == NULL)
MessageBox(hwnd, "Can't realize palette", "Error", MB_OK);
ReleaseDC(hwnd, hdc);