Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function returns the system palette color that will be displayed when the specified color value is used.

Syntax

COLORREF GetNearestColor(
  HDC 
hdc, 
  COLORREF 
crColor
); 

Parameters

hdc

[in] Handle to the device context (DC).

crColor

[in] Specifies a color value that identifies a requested color.

Return Value

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

If the function fails, the return value is CLR_INVALID.

To get extended error information, call GetLastError.

Remarks

The GetNearestColorfunction returns the color from the selected device context that most closely matches the specified color value.

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also