| title | CSize Class | Microsoft Docs | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | reference | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | fb2cf85a-0bc1-46f8-892b-309c108b52ae | |||||||||||||
| caps.latest.revision | 20 | |||||||||||||
| author | mikeblome | |||||||||||||
| ms.author | mblome | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
Similar to the Windows SIZE structure, which implements a relative coordinate or position.
class CSize : public tagSIZE
| Name | Description |
|---|---|
| CSize::CSize | Constructs a CSize object. |
| Name | Description |
|---|---|
| CSize::operator - | Subtracts two sizes. |
| CSize::operator != | Checks for inequality between CSize and a size. |
| CSize::operator + | Adds two sizes. |
| CSize::operator += | Adds a size to CSize. |
| CSize::operator -= | Subtracts a size from CSize. |
| CSize::operator == | Checks for equality between CSize and a size. |
This class is derived from the SIZE structure. This means you can pass a CSize in a parameter that calls for a SIZE and that the data members of the SIZE structure are accessible data members of CSize.
The cx and cy members of SIZE (and CSize) are public. In addition, CSize implements member functions to manipulate the SIZE structure.
Note
For more information on shared utility classes (like CSize), see Shared Classes.
tagSIZE
CSize
Header: atltypes.h
Constructs a CSize object.
CSize() throw();
CSize( int initCX, int initCY) throw();
CSize( SIZE initSize) throw();
CSize( POINT initPt) throw();
CSize( DWORD dwSize) throw();
initCX
Sets the cx member for the CSize.
initCY
Sets the cy member for the CSize.
initSize
SIZE structure or CSize object used to initialize CSize.
initPt
POINT structure or CPoint object used to initialize CSize.
dwSize
DWORD used to initialize CSize. The low-order word is the cx member and the high-order word is the cy member.
If no arguments are given, cx and cy are initialized to zero.
[!code-cppNVC_ATLMFC_Utilities#97]
Checks for equality between two sizes.
BOOL operator==(SIZE size) const throw();
Returns nonzero if the sizes are equal, otherwize 0.
[!code-cppNVC_ATLMFC_Utilities#98]
Checks for inequality between two sizes.
BOOL operator!=(SIZE size) const throw();
Returns nonzero if the sizes are not equal, otherwise 0.
[!code-cppNVC_ATLMFC_Utilities#99]
Adds a size to this CSize.
void operator+=(SIZE size) throw();
[!code-cppNVC_ATLMFC_Utilities#100]
Subtracts a size from this CSize.
void operator-=(SIZE size) throw();
[!code-cppNVC_ATLMFC_Utilities#101]
These operators add this CSize value to the value of parameter.
CSize operator+(SIZE size) const throw();
CPoint operator+(POINT point) const throw();
CRect operator+(const RECT* lpRect) const throw();
See the following descriptions of the individual operators:
-
operator +(
size**)**This operation adds twoCSizevalues. -
operator +(
point**)**This operation offsets (moves) a POINT (or CPoint) value by thisCSizevalue. The cx and cy members of thisCSizevalue are added to the x and y data members of the POINT value. It is analogous to the version of CPoint::operator + that takes a SIZE parameter. -
operator +(
lpRect**)**This operation offsets (moves) a RECT (or CRect) value by thisCSizevalue. The cx and cy members of thisCSizevalue are added to the left, top, right, and bottom data members of theRECTvalue. It is analogous to the version of CRect::operator + that takes a SIZE parameter.
[!code-cppNVC_ATLMFC_Utilities#102]
The first three of these operators subtract this CSize value to the value of parameter.
CSize operator-(SIZE size) const throw();
CPoint operator-(POINT point) const throw();
CRect operator-(const RECT* lpRect) const throw();
CSize operator-() const throw();
The fourth operator, the unary minus, changes the sign of the CSize value. See the following descriptions of the individual operators:
-
operator -(
size**)**This operation subtracts twoCSizevalues. -
operator -(
point**)**This operation offsets (moves) a POINT or CPoint value by the additive inverse of thisCSizevalue. The cx and cy of thisCSizevalue are subtracted from the x and y data members of the POINT value. It is analogous to the version of CPoint::operator - that takes a SIZE parameter. -
operator -(
lpRect**)**This operation offsets (moves) a RECT or CRect value by the additive inverse of thisCSizevalue. The cx and cy members of thisCSizevalue are subtracted from the left, top, right, and bottom data members of theRECTvalue. It is analogous to the version of CRect::operator - that takes a SIZE parameter. -
**operator -( )**This operation returns the additive inverse of this
CSizevalue.
[!code-cppNVC_ATLMFC_Utilities#103]