RECT Structure 和CRect Class
RECT结构体定义了一个矩形的左上角和右下角的坐标:
typedef struct tagRECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
初始化:
RECT rctA;
rctA.left = 20;
rctA.top = 30;
rctA.right = 180;
rctA.bottom = 230;
RECT rctB = {20,30,180,230};
CRect类和Windows RECT结构体是一样的:class CRect : public tagRECT
其中常用的两个构造函数:
CRect( POINT topLeft, POINT bottomRight ) throw( );
CRect( int l, int t, int r, int b ) throw( );
POINT Structure 和CPoint Class
这两个的情况和上面两个基本一致,都已一体两面的问题,实质都一样。
POINT初始化:
POINT ptA; CPoint point(370,550);
ptA.x = 370;
ptA.y = 550;
POINT ptB = {370,550};
综合举例:
POINT ptStart = {370,550}, CPoint ptEnd(400,600);
CRect rect(ptStart, ptEnd );