Graphics.DrawRectangles(const Pen*, const RectF*, INT) method

Applies to: desktop apps only

The Graphics::DrawRectangles method draws a sequence of rectangles.

Syntax

Status DrawRectangles(
  [in]  const Pen *pen,
  [in]  const RectF *rects,
  [in]  INT count
);

Parameters

  • pen [in]
    Type: const Pen*

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

  • rects [in]
    Type: const RectF*

    Pointer to an array of RectF objects that specify the coordinates of the rectangles to be drawn.

  • count [in]
    Type: INT

    Integer that specifies the number of elements in the rects array.

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 group of rectangles.

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

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);
   
   // Create an array of RectF objects.
   RectF rect1(0.0f, 0.0f, 100.0f, 200.0f);
   RectF rect2(100.0f, 200.0f, 250.0f, 50.0f);
   RectF rect3(300.0f, 0.0f, 50.0f, 100.0f);
   RectF rects[] = {rect1, rect2, rect3};
   RectF* pRects = rects;

   // Draw the rectangles.
   graphics.DrawRectangles(&blackPen, pRects, 3);
}

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

Rect

Using a Pen to Draw Lines and Rectangles

Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012