2014220902010-赵天豪-实验5(4)

2019-04-09 15:12

#include // MFC 核心组件和标准组件 #include // MFC 扩展

#include // MFC 自动化类

#ifndef _AFX_NO_OLE_SUPPORT

#include // MFC 对 Internet Explorer 4 公共控件的支持 #endif

#ifndef _AFX_NO_AFXCMN_SUPPORT

#include // MFC 对 Windows 公共控件的支持 #endif // _AFX_NO_AFXCMN_SUPPORT

#include // 功能区和控件条的 MFC 支持

#ifdef _UNICODE #if defined _M_IX86

#pragma comment(linker,\

name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\\\) #elif defined _M_X64

#pragma comment(linker,\

name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\\\) #else

#pragma comment(linker,\

name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\\\) #endif #endif

#include #include

//{{ 你编写的头文件都包含在这里 //}}

using namespace std;

Targetver.h:

#pragma once

// 包括 SDKDDKVer.h 将定义最高版本的可用 Windows 平台。

// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将 // WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。

#include

Trap.h:

#pragma once #include #include #include\ #include \ using namespace std;

class Trapezoid : public Quadrangle { public:

Trapezoid(int w1 = 5.0, int w2 = 7.0, int h = 8.0, string nm = \) :width1(w1), ~Trapezoid();

void draw() const{ Canvas::drawQuad(this); };

double area() const{ return (double)(width1+width2)*height/2; }; string what() const{ return name; }; int Width1(){ return width1; }; int Width2(){ return width2; }; int Height(){ return height; };

friend ostream&operator<<(ostream& os, const Trapezoid &c5); Trapezoid&operator=(const Trapezoid&tr) {

name = tr.name; width1 = tr.width1; width2 = tr.width2;

width2(w2),height(h), Quadrangle(nm){};

};

}

height = tr.height; return *this;

private:

int width1; int width2; int height;

Canvas.cpp:

// Canvas.cpp : 实现文件 //

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

//{{ 外部说明添加到这里 extern List list; //}} // Canvas

Canvas * Canvas::pCanvas = NULL; bool Canvas::isLearning = false;

IMPLEMENT_DYNCREATE(Canvas, CScrollView)

Canvas::Canvas() {

quadMap.insert(KV(\, para)); quadMap.insert(KV(\, rect)); quadMap.insert(KV(\, sqr)); quadMap.insert(KV(\, diam)); quadMap.insert(KV(\, trap)); pCanvas = this;

}

static CString formatString[] = { };

Canvas::~Canvas() { }

BEGIN_MESSAGE_MAP(Canvas, CScrollView)

END_MESSAGE_MAP()

// Canvas 绘图

void Canvas::OnInitialUpdate() { }

union _QUADPTR_ { };

void Canvas::OnDraw(CDC* pDC) {

CDocument* pDoc = GetDocument(); Quadrangle *q; Para *p; Rect *r; Diamond *d; Square *s; Trapezoid *t; //CSize sizeTotal;

// TODO: 计算此视图的合计大小 //sizeTotal.cx = sizeTotal.cy = 100; //SetScrollSizes(MM_TEXT, sizeTotal); CScrollView::OnInitialUpdate(); _T(\宽=%d, 高=%d, 面积=\),

_T(\对角线1=%d, 对角线2=%d, 面积=\), _T(\平行边1=%d, 平行边2=%d, 高=%d, 面积=\)

// TODO: 在此添加绘制代码 CRect rect;

GetClientRect(&rect);

CBrush br(RGB(220, 200, 170));

CBrush * oldBrush = reinterpret_cast(pDC->SelectObject (&br)); int xc, yc;

int vw = rect.Width (), vh = rect.Height ();

int sw = static_cast(vw * 0.75 / 2.0), sh = static_cast(vh * 0.75 / 2.0); SIZE ad[5][4] = { };

double ratio = 1.0; int yOffset = 120; if (isLearning) { } else { }

POINT vert[4]; int shape;

size_t i, begin = 0, end = list.size(); if (isLearning) begin = end - 1; _QUADPTR_ quad; string name; CString msg, msg2; for (i = begin; i<= end; ++i) {

quad.q = list[i]; name = quad.q->what(); xc = 80; yc = 60; ratio = 0.3; xc = vw / 2; yc = vh / 2;

{ { -sw + 50, -sh }, { sw + 50, -sh }, { sw - 50, sh }, { -sw - 50, sh } }, { { -sw, -sh }, { sw, -sh }, { sw, sh }, { -sw, sh } }, { { -sh, -sh }, { sh, -sh }, { sh, sh }, { -sh, sh } }, { { 0, -sh }, { sw, 0 }, { 0, sh }, { -sw, 0 } },

{ { -sw + 120, -sh }, { sw - 80, -sh }, { sw, sh }, { -sw, sh } },


2014220902010-赵天豪-实验5(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:测试技术参考答案(王世勇,前三章)

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

马上注册会员

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