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

2019-09-02 13:38

MFC—课程设计

linewidth=line; }

void CEllipse::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->Ellipse(OrgX - width / 2, OrgY - high / 2, OrgX + width / 2, OrgY width = w; high=h; R1=r1; R2=r2; G1=g1; G2=g2; B1=b1; B2=b2;

+high / 2); }

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

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

41

MFC—课程设计

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

return true;

else

return false;

} //文本

void CText::Serialize(CArchive &ar) { if (ar.IsStoring()) { ar << OrgX<< OrgY;//原点坐标

ar<< linewidth;//线宽 } else { ar >> OrgX >>OrgY;//原点坐标 ar >> linewidth;//线宽 }

}

CText::CText()//缺省构造函数,初始化{ OrgX = 400;//原点坐标 OrgY = 400; }

42

MFC—课程设计

CText::CText(int x,int y,int r1,int g1,int b1,int a) { }

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

CFont * pNewFont=new CFont; OrgX = x;//原点坐标 OrgY = y; R1=r1; G1=g1; B1=b1; angle=a;

CFont * pOldFont;

pNewFont->CreateFont(30,20,angle,0,

200,FALSE,1,FALSE,

ANSI_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH&FF_SWISS, \

pOldFont=(CFont *)pDC->SelectObject(pNewFont); pDC->SetTextColor(RGB(R1,G1,B1));

pDC->TextOut(OrgX,OrgY,\ }

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

if ((OrgX <= pnt.x ) && (OrgY <= pnt.y ))

return true;

43

MFC—课程设计

}

else

return false;

3.LwhView.cpp

// LwhView.cpp : implementation of the CLwhView class //

#include \#include \#include \#include \#include \#include \#include \

#ifdef _DEBUG

#define new DEBUG_NEW #undef THIS_FILE

static char THIS_FILE[] = __FILE__; #endif

///////////////////////////////////////////////////////////////////////////// // CLwhView

IMPLEMENT_DYNCREATE(CLwhView, CView)

BEGIN_MESSAGE_MAP(CLwhView, CView)

44

MFC—课程设计

//{{AFX_MSG_MAP(CLwhView) ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDBLCLK() //}}AFX_MSG_MAP

// Standard printing commands

ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CLwhView construction/destruction

CLwhView::CLwhView() { }

CLwhView::~CLwhView() { }

BOOL CLwhView::PreCreateWindow(CREATESTRUCT& cs) {

// TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs

// TODO: add construction code here

45


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

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

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

马上注册会员

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