In this example, the WinRealizePalette call is issued in response to a WM_REALIZEPALETTE. This ensures that the palette is appropriately realized for all drawing operations.
#define INCL_WIN #include <OS2.H> HWND hwnd; ULONG cclr; USHORT msg; HPS hps; switch(msg) { case WM_REALIZEPALETTE: WinRealizePalette(hwnd,hps,&cclr); }