Skip to content

Latest commit

 

History

History
220 lines (136 loc) · 7.28 KB

csize-class.md

File metadata and controls

220 lines (136 loc) · 7.28 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: CSize Class
CSize Class
10/18/2018
CSize
ATLTYPES/ATL::CSize
ATLTYPES/ATL::CSize::CSize
SIZE
dimensions, MFC
dimensions
CSize class
fb2cf85a-0bc1-46f8-892b-309c108b52ae

CSize Class

Similar to the Windows SIZE structure, which implements a relative coordinate or position.

Syntax

class CSize : public tagSIZE

Members

Public Constructors

Name Description
CSize::CSize Constructs a CSize object.

Public Operators

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.

Remarks

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.

Inheritance Hierarchy

tagSIZE

CSize

Requirements

Header: atltypes.h

CSize::CSize

Constructs a CSize object.

CSize() throw();
CSize( int initCX, int initCY) throw();
CSize( SIZE initSize) throw();
CSize( POINT initPt) throw();
CSize( DWORD dwSize) throw();

Parameters

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.

Remarks

If no arguments are given, cx and cy are initialized to zero.

Example

[!code-cppNVC_ATLMFC_Utilities#97]

CSize::operator ==

Checks for equality between two sizes.

BOOL operator==(SIZE size) const throw();

Remarks

Returns nonzero if the sizes are equal, otherwize 0.

Example

[!code-cppNVC_ATLMFC_Utilities#98]

CSize::operator !=

Checks for inequality between two sizes.

BOOL operator!=(SIZE size) const throw();

Remarks

Returns nonzero if the sizes are not equal, otherwise 0.

Example

[!code-cppNVC_ATLMFC_Utilities#99]

CSize::operator +=

Adds a size to this CSize.

void operator+=(SIZE size) throw();

Example

[!code-cppNVC_ATLMFC_Utilities#100]

CSize::operator -=

Subtracts a size from this CSize.

void operator-=(SIZE size) throw();

Example

[!code-cppNVC_ATLMFC_Utilities#101]

CSize::operator +

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();

Remarks

See the following descriptions of the individual operators:

  • operator +( size )

    This operation adds two CSize values.

  • operator +( point )

    This operation offsets (moves) a POINT (or CPoint) value by this CSize value. The cx and cy members of this CSize value 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 this CSize value. The cx and cy members of this CSize value are added to the left, top, right, and bottom data members of the RECT value. It is analogous to the version of CRect::operator + that takes a SIZE parameter.

Example

[!code-cppNVC_ATLMFC_Utilities#102]

CSize::operator -

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();

Remarks

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 two CSize values.

  • operator -( point )

    This operation offsets (moves) a POINT or CPoint value by the additive inverse of this CSize value. The cx and cy of this CSize value 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 this CSize value. The cx and cy members of this CSize value are subtracted from the left, top, right, and bottom data members of the RECT value. It is analogous to the version of CRect::operator - that takes a SIZE parameter.

  • operator -()

    This operation returns the additive inverse of this CSize value.

Example

[!code-cppNVC_ATLMFC_Utilities#103]

See also

MFC Sample MDI
Hierarchy Chart
CRect Class
CPoint Class