Ex_Draw通过设置窗口和视口大小来改变显示比例

上传人:飞*** 文档编号:50960257 上传时间:2018-08-11 格式:PDF 页数:10 大小:233.28KB
返回 下载 相关 举报
Ex_Draw通过设置窗口和视口大小来改变显示比例_第1页
第1页 / 共10页
Ex_Draw通过设置窗口和视口大小来改变显示比例_第2页
第2页 / 共10页
Ex_Draw通过设置窗口和视口大小来改变显示比例_第3页
第3页 / 共10页
Ex_Draw通过设置窗口和视口大小来改变显示比例_第4页
第4页 / 共10页
Ex_Draw通过设置窗口和视口大小来改变显示比例_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《Ex_Draw通过设置窗口和视口大小来改变显示比例》由会员分享,可在线阅读,更多相关《Ex_Draw通过设置窗口和视口大小来改变显示比例(10页珍藏版)》请在金锄头文库上搜索。

1、通过设置窗口和视口大小来改变显示比例1 面向对象 VC+ 程序设计论文Ex_Draw 通过设置窗口和视口大小来改变显示比例专业班级:姓名:选课序号:学号:信息科学技术学院通过设置窗口和视口大小来改变显示比例第1章绪论1.1 设计目标通过设置窗口和视口的大小来改变显示比例1.1.1 开发平台Visual c+6.0 第二章 设计流程1.1 编译程序1.1.1 创建一个默认的单文本应用程序Ex-Draw。1.1.2在 CEx-DrawView:OnDraw 函数中添加下列代码:void CEx_DrawView:OnDraw(CDC* pDC) CEx_DrawDoc* pDoc = GetDoc

2、ument(); ASSERT_VALID(pDoc); CRectrectClient; GetClientRect(rectClient); pDC-SetMapMode(MM_ANISOTROPIC); pDC-SetWindowExt(1000,1000); pDC-SetViewportExt(rectClient.right,-rectClient.bottom); pDC-SetViewportOrg(rectClient.right/2,rectClient.bottom/2); pDC-Ellipse(CRect(-500,-500,500,500); 1.1.3 编译运行,

3、如下图:通过设置窗口和视口大小来改变显示比例使视图的高度变小,可得到以下结果:再使视图的宽度变小,可得到以下结果:可见当视图的大小发生改变时椭圆的形状也会随之改变。通过设置窗口和视口大小来改变显示比例结论在 Visual c+6.0 开发环境下,设计并实现了通过设置窗口和视口的大小来改变显示比例的功能。通过设置窗口和视口大小来改变显示比例参考文献1 郑阿奇 . Visual C+实用教程(第3 版) ,P301-302.通过设置窗口和视口大小来改变显示比例附录:/ Ex_DrawView.cpp : implementation of the CEx_DrawView class / #inc

4、lude “stdafx.h“ #include “Ex_Draw.h“ #include “Ex_DrawDoc.h“ #include “Ex_DrawView.h“ #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE = _FILE_; #endif / / CEx_DrawView IMPLEMENT_DYNCREATE(CEx_DrawView, CView) BEGIN_MESSAGE_MAP(CEx_DrawView, CView) /AFX_MSG_MAP(CEx_DrawView

5、) / NOTE - the ClassWizard will add and remove mapping macros here. / DO NOT EDIT what you see in these blocks of generated code! /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_PREVIE

6、W, CView:OnFilePrintPreview) END_MESSAGE_MAP() / / CEx_DrawView construction/destruction CEx_DrawView:CEx_DrawView() / TODO: add construction code here CEx_DrawView:CEx_DrawView() 通过设置窗口和视口大小来改变显示比例 BOOL CEx_DrawView:PreCreateWindow(CREATESTRUCT / / CEx_DrawView drawing void CEx_DrawView:OnDraw(CDC*

7、 pDC) CEx_DrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CRect rectClient; GetClientRect(rectClient); pDC-SetMapMode(MM_ANISOTROPIC); pDC-SetWindowExt(1000,1000); pDC-SetViewportExt(rectClient.right,-rectClient.bottom); pDC-SetViewportOrg(rectClient.right/2,rectClient.bottom/2); pDC-Ellipse(CRec

8、t(-500,-500,500,500); / TODO: add draw code for native data here / / CEx_DrawView printing BOOL CEx_DrawView:OnPreparePrinting(CPrintInfo* pInfo) / default preparation return DoPreparePrinting(pInfo); void CEx_DrawView:OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) / TODO: add extra initializa

9、tion before printing void CEx_DrawView:OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 通过设置窗口和视口大小来改变显示比例 / TODO: add cleanup after printing / / CEx_DrawView diagnostics #ifdef _DEBUG void CEx_DrawView:AssertValid() const CView:AssertValid(); void CEx_DrawView:Dump(CDumpContext CEx_DrawDoc* CEx_D

10、rawView:GetDocument() / non-debug version is inline ASSERT(m_pDocument-IsKindOf(RUNTIME_CLASS(CEx_DrawDoc); return (CEx_DrawDoc*)m_pDocument; #endif /_DEBUG / / CEx_DrawView message handlers / Ex_DrawView.h : interface of the CEx_DrawView class / / #if !defined(AFX_EX_DRAWVIEW_H_75E413D2_6D7E_4BDF_9

11、43E_2E417046DC84_INCLUDED_) #define AFX_EX_DRAWVIEW_H_75E413D2_6D7E_4BDF_943E_2E417046DC84_INCLUDED_ #if _MSC_VER 1000 #pragma once #endif / _MSC_VER 1000 通过设置窗口和视口大小来改变显示比例class CEx_DrawView : public CView protected: / create from serialization only CEx_DrawView(); DECLARE_DYNCREATE(CEx_DrawView) /

12、 Attributes public: CEx_DrawDoc* GetDocument(); / Operations public: / Overrides / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CEx_DrawView) public: virtual void OnDraw(CDC* pDC); / overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT protected: virtual BOOL OnPre

13、parePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); /AFX_VIRTUAL / Implementation public: virtual CEx_DrawView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext #endif pro

14、tected: / Generated message map functions protected: /AFX_MSG(CEx_DrawView) / NOTE - the ClassWizard will add and remove member functions here. / DO NOT EDIT what you see in these blocks of generated code ! /AFX_MSG DECLARE_MESSAGE_MAP() 通过设置窗口和视口大小来改变显示比例; #ifndef _DEBUG / debug version in Ex_DrawView.cpp inline CEx_DrawDoc* CEx_DrawView:GetDocument() return (CEx_DrawDoc*)m_pDocument; #endif /

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号