CSize クラスCSize Class
Windows の SIZE 構造体と同様に、相対座標や位置を実装します。Similar to the Windows SIZE structure, which implements a relative coordinate or position.
構文Syntax
class CSize : public tagSIZE
メンバーMembers
パブリック コンストラクターPublic Constructors
名前Name | 説明Description |
---|---|
CSize:: CSizeCSize::CSize | CSize オブジェクトを構築します。Constructs a CSize object. |
パブリック演算子Public Operators
名前Name | 説明Description |
---|---|
CSize:: operator-CSize::operator - | 2つのサイズを減算します。Subtracts two sizes. |
CSize:: operator! =CSize::operator != | とのサイズが等しくないかどうかを確認し CSize ます。Checks for inequality between CSize and a size. |
CSize:: operator +CSize::operator + | 2つのサイズを加算します。Adds two sizes. |
CSize:: operator + =CSize::operator += | にサイズを追加し CSize ます。Adds a size to CSize . |
CSize:: operator-=CSize::operator -= | からサイズを減算 CSize します。Subtracts a size from CSize . |
CSize:: operator = =CSize::operator == | とのサイズが等しいかどうかをチェックし CSize ます。Checks for equality between CSize and a size. |
解説Remarks
このクラスは、 SIZE
構造体から派生します。This class is derived from the SIZE
structure. これは、を呼び出すパラメーターでを渡すことができ、 CSize
SIZE
構造体のデータメンバー SIZE
がのアクセス可能なデータメンバーであることを意味し CSize
ます。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
.
cx
cy
SIZE
(および) のおよびメンバー CSize
はパブリックです。The cx
and cy
members of SIZE
(and CSize
) are public. さらに、は、 CSize
構造体を操作するためのメンバー関数を実装し SIZE
ます。In addition, CSize
implements member functions to manipulate the SIZE
structure.
注意
共有ユーティリティクラス (など) の詳細につい CSize
ては、「 共有クラス」を参照してください。For more information on shared utility classes (like CSize
), see Shared Classes.
継承階層Inheritance Hierarchy
tagSIZE
CSize
要件Requirements
ヘッダー: atltypes. hHeader: atltypes.h
CSize:: CSizeCSize::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
initCXinitCX
のメンバーを設定 cx
CSize
します。Sets the cx
member for the CSize
.
initCYinitCY
のメンバーを設定 cy
CSize
します。Sets the cy
member for the CSize
.
initSizeinitSize
初期化に使用するサイズの構造体または CSize
オブジェクト CSize
。SIZE structure or CSize
object used to initialize CSize
.
initPtinitPt
の CPoint
初期化に使用されるポイント構造またはオブジェクト CSize
。POINT structure or CPoint
object used to initialize CSize
.
dwSizedwSize
初期化に使用する DWORD CSize
。DWORD used to initialize CSize
. 下位ワードはメンバーであり、 cx
上位ワードは cy
メンバーです。The low-order word is the cx
member and the high-order word is the cy
member.
解説Remarks
引数を指定しない場合、 cx
および cy
は0に初期化されます。If no arguments are given, cx
and cy
are initialized to zero.
例Example
CSize szEmpty;
CSize szPointA(10, 25);
SIZE sz;
sz.cx = 10;
sz.cy = 25;
CSize szPointB(sz);
POINT pt;
pt.x = 10;
pt.y = 25;
CSize szPointC(pt);
CPoint ptObject(10, 25);
CSize szPointD(ptObject);
DWORD dw = MAKELONG(10, 25);
CSize szPointE(dw);
ASSERT(szPointA == szPointB);
ASSERT(szPointB == szPointC);
ASSERT(szPointC == szPointD);
ASSERT(szPointD == szPointE);
CSize:: operator = =CSize::operator ==
2つのサイズが等しいかどうかをチェックします。Checks for equality between two sizes.
BOOL operator==(SIZE size) const throw();
解説Remarks
サイズが等しい場合は0以外の値、otherwize は0を返します。Returns nonzero if the sizes are equal, otherwize 0.
例Example
CSize sz1(135, 135);
CSize sz2(135, 135);
ASSERT(sz1 == sz2);
CSize:: operator! =CSize::operator !=
2つのサイズが等しくないかどうかをチェックします。Checks for inequality between two sizes.
BOOL operator!=(SIZE size) const throw();
解説Remarks
サイズが等しくない場合は0以外の値を返します。それ以外の場合は0を返します。Returns nonzero if the sizes are not equal, otherwise 0.
例Example
CSize sz1(222, 222);
CSize sz2(111, 111);
ASSERT(sz1 != sz2);
CSize:: operator + =CSize::operator +=
サイズをこのに追加し CSize
ます。Adds a size to this CSize
.
void operator+=(SIZE size) throw();
例Example
CSize sz1(100, 100);
CSize sz2(50, 25);
sz1 += sz2;
CSize szResult(150, 125);
ASSERT(sz1 == szResult);
// works with SIZE, too
sz1 = CSize(100, 100);
SIZE sz3;
sz3.cx = 50;
sz3.cy = 25;
sz1 += sz3;
ASSERT(sz1 == szResult);
CSize:: operator-=CSize::operator -=
このからサイズを減算 CSize
します。Subtracts a size from this CSize
.
void operator-=(SIZE size) throw();
例Example
CSize sz1(100, 100);
CSize sz2(50, 25);
sz1 -= sz2;
CSize szResult(50, 75);
ASSERT(sz1 == szResult);
// works with SIZE, too
sz1 = CSize(100, 100);
SIZE sz3;
sz3.cx = 50;
sz3.cy = 25;
sz1 -= sz3;
ASSERT(sz1 == szResult);
CSize:: operator +CSize::operator +
これら CSize
の演算子は、この値をパラメーターの値に追加します。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 )
この操作では
CSize
、2つの値を加算します。This operation adds twoCSize
values.演算子 + ( point )operator +( point )
この操作では、この値によって POINT (または CPoint) 値がオフセット (移動) さ
CSize
れます。This operation offsets (moves) a POINT (or CPoint) value by thisCSize
value.cx
cy
この値のおよびメンバーは、CSize
x
値のおよびデータメンバーに追加されy
POINT
ます。Thecx
andcy
members of thisCSize
value are added to thex
andy
data members of thePOINT
value. これは、 SIZEパラメーターを受け取る、 CPoint:: operator +のバージョンに似ています。It is analogous to the version of CPoint::operator + that takes a SIZE parameter.演算子 + ( lpRect )operator +( lpRect )
この操作では、この値によって RECT (または CRect) の値がオフセット (移動) さ
CSize
れます。This operation offsets (moves) a RECT (or CRect) value by thisCSize
value.cx
cy
この値のおよびメンバーは、CSize
left
値の、、、およびの各データメンバーに追加されtop
right
bottom
RECT
ます。Thecx
andcy
members of thisCSize
value are added to theleft
,top
,right
, andbottom
data members of theRECT
value. これは、サイズパラメーターを受け取る、 CRect:: operator +のバージョンに似ています。It is analogous to the version of CRect::operator + that takes a SIZE parameter.
例Example
CSize sz1(100, 100);
CSize sz2(50, 25);
CSize szOut;
szOut = sz1 + sz2;
CSize szResult(150, 125);
ASSERT(szOut == szResult);
// works with SIZE, too
sz1 = CSize(100, 100);
SIZE sz3;
sz3.cx = 50;
sz3.cy = 25;
szOut = sz1 + sz3;
ASSERT(szOut == szResult);
CSize:: operator-CSize::operator -
これらの演算子の最初の3つは、この CSize
値をパラメーターの値に減算します。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
4番目の演算子 (単項マイナス) は、値の符号を変更し CSize
ます。The fourth operator, the unary minus, changes the sign of the CSize
value. 個々の演算子の次の説明を参照してください。See the following descriptions of the individual operators:
operator-( サイズ )operator -( size )
この操作では
CSize
、2つの値を減算します。This operation subtracts twoCSize
values.operator-( point )operator -( point )
この操作では、この値の加法逆によって、 点 または CPoint 値がオフセット (移動) さ
CSize
れます。This operation offsets (moves) a POINT or CPoint value by the additive inverse of thisCSize
value.cx
cy
この値のとは、CSize
x
値のおよびデータメンバーから減算されy
POINT
ます。Thecx
andcy
of thisCSize
value are subtracted from thex
andy
data members of thePOINT
value. これは、 SIZEパラメーターを受け取る、 CPoint:: operatorのバージョンに似ています。It is analogous to the version of CPoint::operator - that takes a SIZE parameter.operator-( lpRect )operator -( lpRect )
この操作は、この値の加法逆によって RECT または CRect の値をオフセット (移動)
CSize
します。This operation offsets (moves) a RECT or CRect value by the additive inverse of thisCSize
value.cx
cy
この値のおよびメンバーは、CSize
left
値の、、、およびの各データメンバーから減算されtop
right
bottom
RECT
ます。Thecx
andcy
members of thisCSize
value are subtracted from theleft
,top
,right
, andbottom
data members of theRECT
value. これは、サイズパラメーターを受け取る、 CRect:: operatorのバージョンに似ています。It is analogous to the version of CRect::operator - that takes a SIZE parameter.operator-()operator -()
この操作は、この値の加法逆を返し
CSize
ます。This operation returns the additive inverse of thisCSize
value.
例Example
CSize sz1(100, 100);
CSize sz2(50, 25);
CSize szOut;
szOut = sz1 - sz2;
CSize szResult(50, 75);
ASSERT(szOut == szResult);
// works with SIZE, too
sz1 = CSize(100, 100);
SIZE sz3;
sz3.cx = 50;
sz3.cy = 25;
szOut = sz1 - sz3;
ASSERT(szOut == szResult);
関連項目See also
MFC のサンプル MDIMFC Sample MDI
階層図Hierarchy Chart
CRect クラスCRect Class
CPoint クラスCPoint Class