Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Rect.Offset(INT, INT) method

Applies to: desktop apps only

The Rect::Offset method moves the rectangle by dx horizontally and by dy vertically.

Syntax

VOID Offset(
  [in]  INT dx,
  [in]  INT dy
);

Parameters

dx [in]

Type: INT

Integer that specifies the amount to move the rectangle horizontally.

dy [in]

Type: INT

Integer that specifies the amount to move the rectangle vertically.

Return value

This method does not return a value.

Examples

The following example creates a Rect object, draws the rectangle, offsets the rectangle, and then redraws the rectangle.


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

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

   // Offset the rectangle and redraw the rectangle.
   rect.Offset(30, 20);
   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
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

Show: