次の方法で共有


RectF.Offset(const PointF&) method

Applies to: desktop apps only

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

Syntax

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

Parameters

  • point [in]
    Type: const PointF&

    Reference to a PointF 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 PointF object and a RectF object and draws the rectangle. The code then offsets the rectangle by the specified PointF object and redraws the rectangle.

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

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

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

   // Offset the rectangle by the PointF 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

RectF

Offset Methods

PointF

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