WM_PALETTECHANGED
hwndPalChg = (HWND) wParam; /* handle of window that changed palette */
The WM_PALETTECHANGED message is sent to all top-level and overlapped windows after the window with the input focus has realized its logical palette, thereby changing the system palette. This message allows a window without the input focus that uses a color palette to realize its logical palette and update its client area.
hwndPalChg
Value of wParam. Specifies the handle of the window that caused the system palette to change.
An application should return zero if it processes this message.
This message is sent to all top-level and overlapped windows, including the one that changed the system palette and caused this message to be sent. If any child windows use a color palette, this message must be passed on to them.
To avoid an infinite loop, a window that receives this message should not realize its palette unless it determines that wParam does not contain its own window handle.
This example shows how an application selects and realizes its logical palette:
HDC hdc;
HPALETTE hpalApp, hpalT;
UINT i;
/*
* If this application changed the palette, ignore the message.
*/
case WM_PALETTECHANGED:
if (wParam == hwnd)
return 0L;
/* Otherwise, fall through to WM_QUERYNEWPALETTE. */
case WM_QUERYNEWPALETTE:
/*
* If realizing the palette causes the palette to change,
* redraw completely.
*/
hdc = GetDC(hwnd);
hpalT = SelectPalette (hdc, hpalApp, FALSE);
i = RealizePalette(hdc); /* i == entries that changed */
SelectPalette (hdc, hpalT, FALSE);
ReleaseDC(hwnd, hdc);
/* If any palette entries changed, repaint the window. */
if (i > 0)
InvalidateRect(hwnd, NULL, TRUE);
return i;