Rectangle function

The Rectangle function draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush.

Syntax


BOOL Rectangle(
  _In_ HDC hdc,
  _In_ int nLeftRect,
  _In_ int nTopRect,
  _In_ int nRightRect,
  _In_ int nBottomRect
);

Parameters

hdc [in]

A handle to the device context.

nLeftRect [in]

The x-coordinate, in logical coordinates, of the upper-left corner of the rectangle.

nTopRect [in]

The y-coordinate, in logical coordinates, of the upper-left corner of the rectangle.

nRightRect [in]

The x-coordinate, in logical coordinates, of the lower-right corner of the rectangle.

nBottomRect [in]

The y-coordinate, in logical coordinates, of the lower-right corner of the rectangle.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

The current position is neither used nor updated by Rectangle.

The rectangle that is drawn excludes the bottom and right edges.

If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less in height and 1 pixel less in width.

Examples

For an example, see Using Filled Shapes.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

See also

Filled Shapes Overview
Filled Shape Functions
RoundRect

 

 

Show: