MFC课程设计实验报告(7)

2019-09-02 13:38

MFC—课程设计

}

}

ar >> linewidth;//线宽

CSquare::CSquare()//缺省构造函数,初始化 { }

CSquare::CSquare(int x, int y, int w,int line,int r1,int g1,int b1,int r2,int b2,int g2) {

OrgX = x;//原点坐标 OrgY = y;

OrgX = 400;//原点坐标 OrgY = 400;

linewidth= 1;//线宽 width = 100;

linewidth=line; }

void CSquare::Draw(CDC*pDC)//绘制函数 {

width = w; R1=r1; R2=r2; G1=g1; G2=g2; B1=b1; B2=b2;

31

MFC—课程设计

CPen pen, *pOldPen;

pen.CreatePen(PS_SOLID, linewidth,RGB(R1,G1,B1)); pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush, *pOldBrush;

brush.CreateHatchBrush(HS_DIAGCROSS, RGB(R2,G2,B2)); pOldBrush = (CBrush*)pDC->SelectObject(&brush);

pDC->Rectangle(OrgX - width / 2, OrgY -width / 2, OrgX + width / 2,

OrgY + width / 2); }

bool CSquare::IsMatched(CPoint pnt)//图元匹配函数 {

if ((OrgX-width/2 <= pnt.x && pnt.x <= OrgX + width/2) && (OrgY - pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush);

width/2 <= pnt.y && pnt.y <= OrgY+width/2)) } //矩形

void CRectangle::Serialize(CArchive &ar) {

if (ar.IsStoring()) {

ar <

return true;

else

return false;

32

MFC—课程设计

}

ar <

ar<< linewidth;//线宽

} else { }

ar >> OrgX >>OrgY;//原点坐标 ar >>width; ar >>high;

ar >> linewidth;//线宽

CRectangle::CRectangle()//缺省构造函数,初始化 { }

CRectangle::CRectangle(int x,int y,int w,int h,int line,int r1,int g1,int b1,int r2,int b2,int g2) {

OrgX = x;//原点坐标 OrgY = y;

OrgX = 400;//原点坐标 OrgY = 400;

linewidth= 1;//线宽 width = 100; high=50;

linewidth=line;

33

MFC—课程设计

}

width = w; high=h; R1=r1; R2=r2; G1=g1; G2=g2; B1=b1; B2=b2;

void CRectangle::Draw(CDC*pDC)//绘制函数 {

CPen pen, *pOldPen;

pen.CreatePen(PS_SOLID, linewidth,RGB(R1,G1,B1)); pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush, *pOldBrush;

brush.CreateHatchBrush(HS_DIAGCROSS, RGB(R2,G2,B2)); pOldBrush = (CBrush*)pDC->SelectObject(&brush);

pDC->Rectangle(OrgX - width / 2, OrgY - high / 2, OrgX + width / 2,

OrgY +high / 2); }

bool CRectangle::IsMatched(CPoint pnt)//图元匹配函数 {

if ((OrgX - width / 2 <= pnt.x && pnt.x <= OrgX + width / 2) && (OrgY pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush);

- high / 2 <= pnt.y && pnt.y <= OrgY + high / 2))

34

MFC—课程设计

}

return true;

else

return false;

//三角形

void CTriangle::Serialize(CArchive &ar) { }

CTriangle::CTriangle()//缺省构造函数,初始化 {

OrgX = 400;//原点坐标 } } else {

ar >> OrgX >> OrgY;//原点坐标 ar >> width; ar >> high; if (ar.IsStoring()) {

ar << OrgX << OrgY;//原点坐标 ar << width; ar << high;

ar << linewidth;//线宽

ar >> linewidth;//线宽

35


MFC课程设计实验报告(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高中数学实施分层教学的研究

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: