次の方法で共有


CRect::CRect

CRect オブジェクトを構築します。

CRect( ) throw( ); 
CRect( 
   int l, 
   int t, 
   int r, 
   int b  
) throw( );
CRect( 
   const RECT& srcRect  
) throw( );
CRect( 
   LPCRECT lpSrcRect  
) throw( );
CRect( 
   POINT point, 
   SIZE size  
) throw( );
CRect( 
   POINT topLeft, 
   POINT bottomRight  
) throw( );

パラメーター

  • l
    CRect の左辺。

  • t
    CRect の上辺。

  • r
    CRect の右辺。

  • b
    CRect の下辺。

  • srcRect
    CRect の座標を持つ RECT 構造体への参照。

  • lpSrcRect
    CRect の座標を持つ RECT 構造体へのポインター。

  • point
    構築される四角形の原点座標。 この座標は四角形の左上隅に相当します。

  • size
    構築される四角形の左上隅から右下隅への距離。

  • topLeft
    CRect の左上の位置。

  • bottomRight
    CRect 右下の位置。

解説

引数が指定されないときは、lefttoprightbottom のメンバーは初期化されません。

CRectconst RECT& ) および CRectLPCRECT ) コンストラクターは、CopyRect 関数を実行します。 その他のコンストラクターは、直接オブジェクトのメンバー変数を初期化します。

使用例

// default constructor doesn't initialize!
CRect rectUnknown;

// four-integers are left, top, right, and bottom
CRect rect(0, 0, 100, 50);
ASSERT(rect.Width() == 100);
ASSERT(rect.Height() == 50);

// Initialize from RECT stucture
RECT sdkRect;
sdkRect.left = 0;
sdkRect.top = 0;
sdkRect.right = 100;
sdkRect.bottom = 50;

CRect rect2(sdkRect);   // by reference
CRect rect3(&sdkRect);  // by address
ASSERT(rect2 == rect);
ASSERT(rect3 == rect);

// from a point and a size
CPoint pt(0, 0);
CSize sz(100, 50);
CRect rect4(pt, sz);
ASSERT(rect4 == rect2);

// from two points
CPoint ptBottomRight(100, 50);
CRect rect5(pt, ptBottomRight);
ASSERT(rect5 == rect4);   

必要条件

**ヘッダー:**atltypes.h

参照

参照

CRect クラス

階層図

CRect::SetRect

CRect::CopyRect

CRect::operator =

CRect::SetRectEmpty

その他の技術情報

CRect のメンバー