Rectangle

2.x

  BOOL Rectangle(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect)    
  HDC hdc; /* handle of device context */
  int nLeftRect; /* x-coordinate upper-left corner */
  int nTopRect; /* y-coordinate upper-left corner */
  int nRightRect; /* x-coordinate lower-right corner */
  int nBottomRect; /* y-coordinate lower-right corner */

The Rectangle function draws a rectangle, using the current pen. The interior of the rectangle is filled by using the current brush.

Parameters

hdc

Identifies the device context.

nLeftRect

Specifies the logical x-coordinate of the upper-left corner of the rectangle.

nTopRect

Specifies the logical y-coordinate of the upper-left corner of the rectangle.

nRightRect

Specifies the logical x-coordinate of the lower-right corner of the rectangle.

nBottomRect

Specifies the logical y-coordinate of the lower-right corner of the rectangle.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The figure this function draws extends up to, but does not include, the
right and bottom coordinates. This means that the height of the figure is
nBottomRect
nTopRect and the width of the figure is nRightRectnLeftRect.

Both the width and the height of a rectangle must be greater than 2 units and less than 32,767 units.

Example

The following example uses a RECT structure to store the coordinates used by the Rectangle function:

HDC hdc;

RECT rc = { 10, 10, 180, 140 };
Rectangle(hdc, rc.left, rc.top,
    rc.right, rc.bottom);

See Also

PolyLine, RoundRect