CPoint operator +( SIZE size ) const;
CPoint operator +( POINT point ) const;
CRect operator +( const RECT* lpRect ) const;
Return Value
A CPoint that is offset by a size, a CPoint that is offset by a point, or a CRect offset by a point.
Parameters
size
Contains a SIZE structure or CSize object.
point
Contains a POINT structure or CPoint object.
lpRect
Contains a pointer to a RECT structure or CRect object.
Remarks
Use this operator to offset CPoint by a CPoint or CSize object, or to offset a CRect by a CPoint.
For example, using one of the first two overloads to offset the point
CPoint(25, -19)
by a point CPoint(15, 5)
or size CSize(15, 5)
returns the value CPoint(40, -14)
.
Adding a rectangle to a point returns the rectangle after being offset by the the x and y values specified in the point. For example, using the last overload to offset a rectangle CRect(125, 219, 325, 419)
by a point CPoint(25, -19)
returns CRect(150, 200, 350, 400)
.
Example
CPoint ptStart(100, 100);
CSize szOffset(35, 35);
ptStart += szOffset;
CPoint ptResult(135, 135);
ASSERT(ptResult == ptStart);
// also works on SIZE
ptStart = CPoint(100, 100);
SIZE sz;
sz.cx = 35;
sz.cy = 35;
ptStart += sz;
ASSERT(ptResult == ptStart);
CPoint Overview | Class Members | Hierarchy Chart
See Also CPoint::operator –=, CPoint::operator –, CPoint::operator +=, CSize::operator +, CRect::operator +, CPoint::Offset, CRect::OffsetRect