Graphics::DrawRectangle(constPen*,constRectF&) method (gdiplusgraphics.h)

The Graphics::DrawRectangle method draws a rectangle.

Syntax

Status DrawRectangle(
  const Pen     *pen,
  const RectF & rect
);

Parameters

pen

Pointer to a Pen that is used to draw the rectangle.

rect

Reference to the rectangle to be drawn.

Return value

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

Examples

The following example draws a rectangle.

VOID Example_DrawRectangle2(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);

   // Create a RectF object.
   RectF rect(0.0f, 0.0f, 200.0f, 200.0f);

   // Draw rect.
   graphics.DrawRectangle(&blackPen, rect);
}

Requirements

Requirement Value
Header gdiplusgraphics.h

See also

DrawRectangles Methods

FillRectangle Methods

Graphics

Pens, Lines, and Rectangles

RectF

Using a Pen to Draw Lines and Rectangles