Share via


Rect.Offset(const Point&) method

Applies to: desktop apps only

The Rect::Offset method moves this rectangle horizontally a distance of point.X and vertically a distance of point.Y.

Syntax

VOID Offset(
  [in]  const Point& point
);

Parameters

  • point [in]
    Type: const Point&

    Reference to a Point object whose X data member specifies the distance to move the rectangle horizontally and whose Y data member specifies the distance to move the rectangle vertically.

Return value

This method does not return a value.

Examples

The following example creates a Point object and a Rect object and draws the rectangle. The code then offsets the rectangle by the specified Point object and redraws the rectangle.

VOID Example_OffsetPoint(HDC hdc)
{
   Graphics graphics(hdc);
   Pen pen(Color(255, 0, 0, 0));

   // Create a Point object.
   Point point(30, 20);

   // Create a Rect object, and then draw the rectangle.
   Rect rect(100, 100, 80, 40);
   graphics.DrawRectangle(&pen, rect);

   // Offset the rectangle by the point object.
   rect.Offset(point);

   // Redraw the rectangle.
   graphics.DrawRectangle(&pen, rect);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplustypes.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Rect

Offset Methods

Point

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