Mega Code Archive

 
Categories / Delphi / Graphic
 

How to determine if current screen display is using more than 256 colors

Title: How to determine if current screen display is using more than 256 colors Question: How do I determine if the current screen display uses more than 256 colors? Answer: If you application uses 256 color bitmaps, or any color not in the standard Windows 16 color palette, you need to take special care to ensure that everything will look right on any display device. This includes responding to the WM_QUERYNEWPALETTE and WM_PALETTECHANGED messages, calling RealizePalette when appropriate, using the same palette for all 256 color bitmaps, and avoiding using non-standard colors (phew!). This function will give an indication whether all this is necessary. function IsHighColor: boolean; var SDC: HDC; begin SDC := GetDC(0); Result := (GetDeviceCaps (SDC, NUMCOLORS) ReleaseDC(0, SDC); end;