欢迎来到天天文库
浏览记录
ID:31750033
大小:69.46 KB
页数:11页
时间:2019-01-17
《vcmfc鼠标做图编程实验》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、一、实验目的(1)熟悉VisualC++6.0开发环境;(2)掌握应用MFC类库编写鼠标绘图程序的方法;(3)掌握MFC环境中绘图函数的使用方法。二、实验内容创建一个单文档应用程序,实现鼠标的绘图功能。要求:(1)创建一个工具栏,有线段、矩形、椭圆三个按钮;(2)绘图前,选择工具栏上的按钮,确定图形的形状。按下鼠标左键,开始绘图,结合鼠标的光标坐标值,来确定图形的形状和大小,并随着鼠标的移动在屏幕上实时绘制图形,放开鼠标左键,确定最后的图形,绘制在屏幕上。三、实验处理列表实现绘图功能的代码清单:1、P
2、ic.h代码如下#if!defined(AFXPICH00F5F2B9A2A64ED6907EEC07AA168545INCLUDED)#defineAFX_PIC_H_00F5F2B9_A2A6_4ED6_907E_EC07AA168545_INCLUDED#if_MSC_VER>1000#pragmaonce#endif//MSCVER>1000classCPicpublic:CPic();virtual〜CPic();voidDraw(CDCPDC);public:UINTm_nDrawType
3、;intm_nX0;intm_nY0;intm_nX1;intm_nY1;};#endif//!defined(AFXPICH00F5F2B9A2A64ED6907EEC07AA168545_INCLUDED_)2、Pic.cpp代码如下://Pic.cpp:implementationoftheCPicclass・////////////////////////////////////////////////////////////////////////#include"stdafx.h"#inc
4、ludeHShiyan8.hn#include"Pic.h"#ifdef.DEBUG#undefTHIS.FILEstaticcharTHIS_FILE[]=_FILE#definenewDEBUG_NEW#endifllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllIIConstruction/DestructionCPic::CPic(){}CPic::〜CPic(){}voidCPic::Draw(CDCp
5、DC){CPenPenLN,pOldPen;PenLN.CreatePen(PS_SOLID,3,RGB(255,0,0));pOldPen=pDC->SelectObject(&PenLN);switch(m_nDrawType){case0:pDC->MoveTo(m_nX0,m_nY0);pDC->LineTo(m_nX1,m_nY1);break;case1:pDC->Ellipse(m_nXO,m_nY0,m_nX1,m_nY1);break;case2:pDC->Rectangle(m_n
6、XO,m_nY0,m_nX1,m_nY1);break;pDC->SelectObject(pOldPen);(od肛MwcpiEpdnuo工oaraTHd人jlmv爼cFcn乜NiTadA±Mv^a~ai)H9NVB-in_aNvwwoD_Hjyadn~NO(od/CjLAwguoaoara一日d人丄AW爼(TGI6aNn-adA±MVHa_ai)H9NVH~aNvwwoD_NOdVW_9SWXJV{{//OdHNOlin9TWM~N0()日ao驸日snoiAri/VArNo()NMoaNoi±na
7、TwM~NO(QAl?S9JlJMPJ(J9)BpdflUO6aAvsmid[-MVHa-ai)in_aNvwwoD_Hjyadfi_NO(oaesoiijmpjquo6HAVsmu~MVBa_ai)aNvwwoD~NO(U9dO9JlJMPJQ9)BpdflUO6NHdomid[-MVHa-ai)in_aNvwwoD_Hjyadfi_NO(u^do^ndMujauo6NHdoanH~MVHa_ai)aNvwwoD~NO(M9iA8UBXiqsD)dVW_9SW-XJV}}//(M9!A0^iA8un
8、XTqsD)dVWH9VSSHWNI9H9(^!AD6M9iA8™Xiqs3)HJVHHDNAa~±NawmdWIZA8U叭qSO//lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllJ!PU。#mid-=LJmH~siH±」叫3①讯艮midTSIHljopun#MHN_onaaa必兀。叫即#onaracF戶PJ!#uq-M9iA8unAiqSH^pn
此文档下载收益归作者所有