CPoint::operator -

使用前两个重载之一从 CPoint减去 CPointCSize 对象。

CSize operator -(
   POINT point 
) const throw( );
CPoint operator -(
   SIZE size 
) const throw( );
CRect operator -(
   const RECT* lpRect 
) const throw( );
CPoint operator -( ) const throw( );

参数

返回值

CSize 点,可由大小、 CRect 可由均之间的差异的非点,或者 CPoint 非是点的求反 CPoint

备注

第三个重载偏移量。CPoint求反的 CRect。 最后,使用一元运算符求反 CPoint

例如,用于查找的第一个重载两个之间的差异点 CPoint(25, -19),并 CPoint(15, 5) 返回 CSize(10, -24)。

减去 CSizeCPoint 执行计算以及上述相同,但返回 CPoint 对象,而不是 CSize 对象。 例如,用于查找第二个重载该点 CPoint(25, -19) 和该范围 CSize(15, 5) 之间的差异返回 CPoint(10, -24)。

减去矩形从点由点指定的 xy 值的负返回矩形偏移量。 例如,使用可补偿的最后一个重载只是点 CPoint(25, -19) 的矩形 CRect(125, 200, 325, 400) 返回 CRect(100, 219, 300, 419)。

使用一元运算符对点。 例如,使用具有点的一元运算符 CPoint(25, -19) 返回 CPoint(-25, 19)。

示例

// example for CPoint subtraction
CPoint   ptStart(100, 100);
CSize   szOffset(35, 35);
CPoint   ptEnd;

ptEnd = ptStart - szOffset;

CPoint   ptResult(65, 65);

ASSERT(ptResult == ptEnd);

// also works on SIZE

ptStart = CPoint(100, 100);

SIZE   sz;
sz.cx = 35;
sz.cy = 35;

ptEnd = ptStart - sz;

ASSERT(ptResult == ptEnd);

// example for CPoint unary operator
CPoint   pt(35, 35);
pt = -pt;

CPoint ptNeg(-35, -35);
ASSERT(pt == ptNeg);   

要求

Header: atltypes.h

请参见

参考

CPoint选件类

层次结构图

CPoint::operator - =

CPoint::operator +=

CPoint::operator +

CSize::operator -

CRect::operator -

CPoint::Offset

CRect::OffsetRect