Windows程序设计作业报告-MFC多功能计算器.doc_第1页
Windows程序设计作业报告-MFC多功能计算器.doc_第2页
Windows程序设计作业报告-MFC多功能计算器.doc_第3页
Windows程序设计作业报告-MFC多功能计算器.doc_第4页
Windows程序设计作业报告-MFC多功能计算器.doc_第5页
免费预览已结束,剩余19页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

windows程序设计作业报告设计题目:mfc多功能计算器学 院:宿迁学院专业班级:软件工程(1)班学生姓名:学生学号:指导教师:提交时间:2011年 12月 15日成 绩:目录1. 课程设计目的及要求 31.1设计目的及问题描述 31.2设计要求31.3软件、硬件环境32. 课程设计步骤32.1 windows消息处理机制的理解32.2界面的设计43. 课程设计内容53.1 概要设计53.1.1 程序总体框架描述83.1.2程序常用类声明8 3.2主要技术113.3系统设计结果 (界面截图、操作流程)224.课程设计总结234.1遇到的问题及如何解决23一、课程设计目的及要求1.1设计目的及问题描述 能够熟练掌握mfc中的各个控件,消息的处理与添加,并且能够具体实现一些功能,真正可以利用功能比较强大的mfc编译出较好的程序代码。此次本人设计的是一个具有比较齐全运算功能的计算器。1.2设计要求 利用microsoft visual c+的mfc制作一个多功能计算器,要求:(1) 能够实现最基本的加、减、乘、除四则基本运算;(2) 计算机界面设置有a、b、c、d、e、f多功能按键;(3) 设置了运算结果转换功能,分别是十进制、八进制、二进制、十六进制;(4) 添加了计算类型,分别是弧度制、度数制;(5) 界面有清空、退格按钮,方便用户计算使用;(6) 重点是此计算器具有多次方、开方、三角函数、反三角函数、取模等高级运算。1.3软件、硬件环境 本程序采用microsoft visual c+6.0的英文版本进行编译。visualc+6.0是microsoft公司推出的基于windows操作系统的可视化c+编程工具,尽管microsoft公司推出了.net平台的集成开发环境,但由于其良好的界面和可操作性,加上支持标准c/c+规范,但仍有相当多的编程人员使用visualc+6.0进行应用系统的开发。一、 课程设计步骤 2.1 windows消息处理机制的理解首先编写程序需要对windows程序的消息处理机制有个比较清晰的了解。windows的程序都是通过消息来传送数据,有不需要用户参与的系统消息,比如异常处理等。2.2界面的设计仿照windows附件里面的计算器,在dialog视图中画好界面,如图: 主要使用的菜单中的相关控件,并合理布置各个按钮的位置,使界面更加整洁。在各个控件的属性里依次定义好名称,之后屏幕显示的就是如图一样的可视计算器界面。以及关于本人和该mfc多功能计算器的相关介绍与信息。三、课程设计内容 3.1 概要设计 依次将各个功能按钮设置相关的id和控件类以上为数字09的属性设置,及其id和标题名称以上为功能a、b、c、d、e、f中的a的属性,及其id和标题名称以上为四则运算加、减、乘、除中“*”的id和标题名称以上为计算器中结果转换和计算类型的属性设置以上为计算器中的次方运算的属性设置以上为计算器中三角函数和反三角函数的属性设置以上是做的一个简单的运算,结果如图中的显示,为double型。3.1.1 程序总体框架描述 mfc多功能计算器计算器的主要功能四则运算三角函数、三角反函数运算的实现二次方、三次方、多次方功能实现结果转换(二、八、十、十六)计算类型(弧度、度数)按键09按键af3.1.2程序常用类声明按键09的id设置idc_button0 idc_button1 idc_button2idc_button3 idc_button4 idc_button5idc_button6 idc_button7 idc_button8idc_button9按键af的id设置idc_buttona idc_buttonb idc_buttoncidc_buttond idc_buttone idc_buttonf结果转换的id设置十进制:idc_btn_dec二进制:idc_btn_bin八进制:idc_btn_oct十六进制:idc_btn_hex计算类型的id设置弧度:idc_btn_radians度数:idc_btn_degress次方的id设置xy:idc_btn_xy x3:idc_btn_cube x2:idc_btn_square三角函数的id设置sin:idc_btn_sin cos:idc_btn_cos tan:idc_btn_tan cot:idc_btn_cot反三角函数的id设置arcsin:idc_btn_arcsin arcos:idc_btn_arccos arctan:idc_btn_arctan arccot:idc_btn_arccot四则运算的id设置+:idc_btn_add :idc_btn_decrease :idc_btn_multi /:idc_btn_div清空、等于、正负号、取模、退格ln、log的id设置/:idc_btn_sign =:idc_btn_equal 清空:idc_btn_ac取模:idc_btn_mod 退格: idc_btn_back 开方:idc_btn_extln: idc_btn_ln log:idc_btn_log下图是在基本对话框中的所有类 3.2主要技术 计算器主要功能的实现09数字的代码(如下)void cmy7139dlg:onbutton0() /todo: add your control notification handler code herem_edit=m_edit+0;setdlgitemtext(idc_edit1,m_edit);void cmy7139dlg:onbutton1() /todo: add your control notification handler code herem_edit=m_edit+1;setdlgitemtext(idc_edit1,m_edit);void cmy7139dlg:onbutton2() /todo: add your control notification handler code herem_edit=m_edit+2;setdlgitemtext(idc_edit1,m_edit);void cmy7139dlg:onbutton9() /todo: add your control notification handler code herem_edit=m_edit+9;setdlgitemtext(idc_edit1,m_edit);加减乘除法的实现:void cmy7139dlg:onbtnadd() / todo: add your control notification handler code heretemp=m_edit;op=+;m_edit=_t();point=false;void cmy7139dlg:onbtndecrease() / todo: add your control notification handler code heretemp=m_edit;op=-;m_edit=_t();point=false;void cmy7139dlg:onbtndecrease() / todo: add your control notification handler code heretemp=m_edit;op=*;m_edit=_t();point=false;void cmy7139dlg:onbtndecrease() / todo: add your control notification handler code heretemp=m_edit;op=/;m_edit=_t();point=false;次方的实现:void cmy7139dlg:onbtnxy() / todo: add your control notification handler code herepotemp=m_edit;op=;m_edit=_t();int=false;三次方的实现(二次方的实现同理):void cmy7139dlg:onbtncube() / todo: add your control notification handler code herechar ch250;int squ3;int squ4;double temp3;double temp4;switch(form)case h: squ3=_tcstoul(m_edit, 0, 16); squ4=pow(squ3,3); m_edit.format(%x,squ4); setdlgitemtext(idc_edit1,m_edit); break;case d: temp3 = atof(lpctstr)m_edit); temp4=pow(temp3,3); m_edit.format(%f,temp4); setdlgitemtext(idc_edit1,m_edit); point=true; break; case o: squ3=_tcstoul(m_edit, 0, 8); squ4=pow(squ3,3); m_edit.format(%o,squ4); setdlgitemtext(idc_edit1,m_edit); break;case b: squ3=_tcstoul(m_edit, 0, 2); squ4=pow(squ3,3); itoa(squ4,ch2,2); m_edit.format(%s,ch2); setdlgitemtext(idc_edit1,m_edit); break; default: return;三角函数的实现:void cmy7139dlg:onbtnsin() / todo: add your control notification handler code heredouble sintemp;switch(degngra)case 1:sintemp=atof(lpctstr)m_edit); m_edit.format(%f,sin(sintemp * pi/180); setdlgitemtext(idc_edit1,m_edit); break;case 2:sintemp=atof(lpctstr)m_edit); m_edit.format(%f,sin(sintemp); setdlgitemtext(idc_edit1,m_edit); break;void cmy7139dlg:onbtncos() / todo: add your control notification handler code heredouble costemp;switch(degngra)case 1:costemp=atof(lpctstr)m_edit); m_edit.format(%f,cos(costemp * pi/180); setdlgitemtext(idc_edit1,m_edit); break;case 2:costemp=atof(lpctstr)m_edit); m_edit.format(%f,cos(costemp); setdlgitemtext(idc_edit1,m_edit); break;void cmy7139dlg:onbtntan() / todo: add your control notification handler code heredouble tantemp;switch(degngra)case 1:tantemp=atof(lpctstr)m_edit);if(tantemp!=90) m_edit.format(%f,tan(tantemp * pi/180); setdlgitemtext(idc_edit1,m_edit); else messagebox(操作数范围错误,error!); m_edit=_t(); point=false; setdlgitemtext(idc_edit1,m_edit); break;case 2:tantemp=atof(lpctstr)m_edit); if(tantemp!=pi/2)m_edit.format(%f,tan(tantemp); setdlgitemtext(idc_edit1,m_edit);elsemessagebox(操作数范围错误,error!); m_edit=_t();point=false;setdlgitemtext(idc_edit1,m_edit);break;void cmy7139dlg:onbtncot() / todo: add your control notification handler code heredouble cottemp;switch(degngra)case 1:cottemp=atof(lpctstr)m_edit);if(cottemp!=0) m_edit.format(%f,1/tan(cottemp * pi/180); setdlgitemtext(idc_edit1,m_edit); else messagebox(操作数范围错误,error!); m_edit=_t(); point=false; setdlgitemtext(idc_edit1,m_edit); break;case 2:cottemp=atof(lpctstr)m_edit); if(cottemp!=0) m_edit.format(%f,1/tan(cottemp); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数范围错误,error!); m_edit=_t(); point=false; setdlgitemtext(idc_edit1,m_edit); break;反函数的实现:void cmy7139dlg:onbtnarcsin() / todo: add your control notification handler code heredouble arcsintemp;arcsintemp=atof(lpctstr)m_edit); if(arcsintemp=-1 & arcsintemp=-1 & arccostemp0) m_edit.format(%x,(int)log10(logt); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break;case d: logtemp=atof(lpctstr)m_edit);if(logtemp0) m_edit.format(%f,log10(logtemp); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break; case o: logt=_tcstoul(m_edit, 0, 8);if(logt0) m_edit.format(%o,(int)log10(logt); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break;case b: logt=_tcstoul(m_edit, 0, 2);if(logt0) itoa(log10(logt),logch,2); m_edit.format(%s,logch); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break; default: return;void cmy7139dlg:onbtnln() / todo: add your control notification handler code heredouble lntemp;int lnt;char lnch50;switch(form)case h: lnt=_tcstoul(m_edit, 0, 16);if(lnt0) m_edit.format(%x,(int)log(lnt); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break;case d: lntemp=atof(lpctstr)m_edit);if(lntemp0) m_edit.format(%f,log(lntemp); setdlgitemtext(idc_edit1,m_edit);else messagebox(操作数应大于零,error!); m_edit=_t();point=false; updatedata(false); break; case o: lnt=_tcstoul(m_edit, 0, 8);if(lnt0)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论