GetNearestColor function (wingdi.h)

The GetNearestColor function retrieves a color value identifying a color from the system palette that will be displayed when the specified color value is used.

Syntax

COLORREF GetNearestColor(
  [in] HDC      hdc,
  [in] COLORREF color
);

Parameters

[in] hdc

A handle to the device context.

[in] color

A color value that identifies a requested color. To create a COLORREF color value, use the RGB macro.

Return value

If the function succeeds, the return value identifies a color from the system palette that corresponds to the given color value.

If the function fails, the return value is CLR_INVALID.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

COLORREF

Color Functions

Colors Overview

GetDeviceCaps

GetNearestPaletteIndex

RGB