SetPixel

Syntax

DWORD SetPixel(hDC,X,Y,crColor)

This function sets the pixel at the point specified by the X and Y parameters to the closest approximation of the color specified by the crColor parameter. The point must be in the clipping region. If the point is not in the clipping region, the function is ignored.

Parameter Type/Description  

hDC HDC Identifies the device context.  
X int Specifies the logical x-coordinate of the point to be set.  
Y int Specifies the logical y-coordinate of the point to be set.  
crColor COLORREF Specifies the color used to paint the point.  

Return Value

The return value specifies an RGB color value for the color that the point is actually painted. This value can be different than that specified by the crColor parameter if an approximation of that color is used. If the function fails (if the point is outside the clipping region) the return value is –1.

Comments

Not all devices support the SetPixel function. For more information, see the RC_BITBLT capability in the GetDeviceCaps function, earlier in this chapter.