1、 计计 算算 机机 MFC 课课 程程 设设 计计 报报 告告 模模 拟拟 计计 算算 器器 姓 名 :姓 名 : 学 号 :学 号 : 联 系 电 话 :联 系 电 话 : 指 导 教 师 :指 导 教 师 : 2012 年年 10 月月 14 日日 模拟计算器 摘要 摘要内容:以课本简单计算器为基础,首先实现了加、减、乘、除、求倒数和平 方根的混合运算, 并能进行清屏及倒退操作, 然后自行完善了书中未能实现的乘、 除运算的连续操作,最后自行设计并完成了lg、ln 、sin、cos、.、pi、e 八个按钮控件的消息映射及程序代码的添加和修改。 从中学会了制作简单的基于 对话框的小工具、掌握了
2、常用控件的使用、明白了消息映射及消息处理、提高了 VC+编程水平。 关键词:四则运算 小数点 计算器 Analog calculator Abstract Content of abstract: Simple calculator in textbooks as the foundation, first realized the addition, subtraction, multiplication, division, and reciprocal and square root of the mixed operation, and can clear screen and rev
3、erse operation, and then to improve the book failed to realize the multiplication, division operation of continuous operation, and finally to be designed and completed the eight button control news mapping and program code to add and modify. Learnt how to make simple dialog-based small tools, master
4、ed the use of commonly used controls, see news mapping and information processing, improve the level of programming. Key word: arithmetic Decimal point Calculator 本计算器是基于 VC+的 MFC 编程,可完成大多数简单操作,其运行后界 面如下图: 以课本简单计算器为基础,首先实现了加、减、乘、除、求倒数和平方根的混合 运算,并能进行清屏及倒退操作,然后自行完善了书中未能实现的乘、除运算的 连续操作,最后自行设计并完成了 lg、ln
5、、sin、cos、.、pi、e 八个按钮控 件的消息映射及程序代码的添加和修改。 完整的操作步骤: 1、创建 MFC 应用程序框架。使用 MFC AppWizard【exe】向导生成一个基于对 话框的应用程序 Calculator。 2、编辑对话框。按图添加前 21 个控件,其中 1 个为编辑框,20 个为按钮,控 件 ID 及 Caption设置如下: IDC_EDIT_PUTOUT IDC_NUMBER1 1 IDC_NUMBER2 2 IDC_NUMBER3 3 IDC_NUMBER4 4 IDC_NUMBER5 5 IDC_NUMBER6 6 IDC_NUMBER7 7 IDC_NUMBER8 8 IDC_NUMBER9 9 IDC_NUMBER0 0 IDC_ADD + IDC_SUBTRACT - IDC_MULTIPLY * IDC_DIVIDE / IDC_RESULT = IDC_MINUS +/- IDC_BACK Back IDC_CLEAR Clear IDC_SQRT Sqrt IDC_RECIPROCAL 1/x IDC_LG lg IDC_LN ln IDC_SIN sin IDC_COS cos IDC_CHENGFANG