Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Graphics.DrawRectangle(const Pen*, const RectF) method

Applies to: desktop apps only

The Graphics::DrawRectangle method draws a rectangle.

Syntax

Status DrawRectangle(
  [in]       const Pen *pen,
  [in, ref]  const RectF &rect
);

Parameters

pen [in]

Type: const Pen*

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

rect [in, ref]

Type: const RectF

Reference to the rectangle to be drawn.

Return value

Type:

Type: Status

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.

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

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
DrawRectangles Methods
FillRectangle Methods
RectF
Using a Pen to Draw Lines and Rectangles
Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2015 Microsoft