FillRect

  int FillRect(hdc, lprc, hBrush)    
  HDC hdc; /* handle of device context */
  CONST RECT *lprc; /* address of structure with rectangle */
  HBRUSH hBrush; /* handle of brush */

This function fills a given rectangle by using the specified brush. The FillRect function fills the complete rectangle, including the left and top borders, but does not fill the right and bottom borders.

Parameters

hdc

Identifies the device context.

lprc

Points to a RECT structure that contains the logical coordinates of the rectangle to be filled.

hBrush

Identifies the brush used to fill the rectangle.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The brush must have been created previously by using either the CreateHatchBrush, CreatePatternBrush, or CreateSolidBrush function, or retrieved using the GetStockObject function.

When filling the specified rectangle, the FillRect function does not include the rectangle's right and bottom sides. GDI fills a rectangle up to, but does not include, the right column and bottom row, regardless of the current mapping mode.

FillRect compares the values of the top, bottom, left, and right members of the specified rectangle. If bottom is less than or equal to top, or if right is less than or equal to left, the rectangle is not drawn.

See Also

CreateHatchBrush, CreatePatternBrush, CreateSolidBrush, GetStockObject