计算器设计报告简易计算器的设计报告Word格式文档下载.docx
- 文档编号:8041444
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:19
- 大小:16.91KB
计算器设计报告简易计算器的设计报告Word格式文档下载.docx
《计算器设计报告简易计算器的设计报告Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《计算器设计报告简易计算器的设计报告Word格式文档下载.docx(19页珍藏版)》请在冰点文库上搜索。
3
四则代码如下
voidCCALDlg:
:
OnButtonequal()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
UpdateData(TRUE);
num2=m_str;
if(num2==0&
&
ope==3)
m_str1="
除数不能为零"
;
m_str=0;
num1=0;
num2=0;
UpdateData(FALSE);
}
else{
//intf=0;
switch(ope)
//加
case0:
m_str=num1+num2;
peak;
//减
case1:
m_str=num1-num2;
5
4系统详细设计
4.1设计步骤
打开MicrosoftVisualC++6.0,在文件中点击新建,在弹出框内选择MFCAppWizard[exe]工程,输入工程名yeyahui及其所在位置,点击确定,如图4-
1所示。
图4-1新建MFCAppWizard[exe]工程
将弹出MFCAppWizard-step1对话框,选择基本对话框,点击完成,如图4-2所示。
7
图4-3新建的对话框
4.2界面设计
界面设计主要是创建控件,在图4-3所示的Resoure
View选项卡中打开Dialog资源组,双击IDD_ZHOUTONG_DIALOG,在右边的窗口中显示出待的对话框。
开始摆放控件,包括框和按钮的创建。
按钮的创建以“1”为例进行介绍,其他按钮的创建可参照此进行操作。
1)在图4-
3中Controls的“框”按钮上单击鼠标左键,在对话框窗口上合适的位置按下鼠标左键并拖动鼠标画出一个大小合适的框。
在框上单击鼠标右键,在弹出的快捷莱单中选择属性选项,此时弹出Edit属性对话框,如图4-4所示,在该对话框中输入ID属性。
9
图5-1四则运算,乘法测试结果图
13
附录
附录1源程序清单
//计算器Dlg.cpp:
implementationfile
//
#include"
stdafx.h"
CAL.h"
CALDlg.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);
//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
CAboutDlg():
CDialog(CAboutDlg:
IDD)
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
voidCAboutDlg:
DoDataExchange(CDataExchange*pDX)
CDialog:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
15
//CCALDlgmessagehandlers
BOOLCCALDlg:
OnInitDialog()
OnInitDialog();
//Add"
About..."
menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemmandrange.
ASSERT((IDM_ABOUTBOX&
0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
pSysMenu->
AppendMenu(MF_SEPARATOR);
AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication"
smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);
//Setbigicon
SetIcon(m_hIcon,FALSE);
//Setsmallicon
SetWindowText(_T("
计算器V1.0:
13级数学与计算机学院第4期陈菁"
));
//修改软件名称
Addextrainitializationhere
returnTRUE;
//returnTRUEunlessyousetthefocustoacontrol
OnSysCommand(UINTnID,LPARAMlParam)
if((nID&
0xFFF0)==IDM_ABOUTBOX)
CAboutDlgdlgAbout;
dlgAbout.DoModal();
else
OnSysCommand(nID,lParam);
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
OnPaint()
if(IsIconic())
CPaintDCdc(this);
//devicecontextforpainting
17
OnButton3()
AddyourcontrolnotificationhandlercodehereUpdateData(TRUE);
m_str=m_str+3;
OnButton4()
m_str=m_str+4;
OnButton5()
m_str=m_str+5;
OnButton6()
m_str=m_str+6;
OnButton7()
m_str=m_str+7;
OnButton8()
19
case2:
m_str=num1*num2;
case3:
m_str=num1/num2;
case4:
m_str=num1*num1;
OnButtonmul()
AddyourcontrolnotificationhandlercodehereSaveValue1();
ope=2;
OnButtondiv()
ope=3;
OnButton10()
Addyourcontrolnotificationhandlercodeherenum1=m_str;
ope=4;
21
内容仅供参考
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算器 设计 报告 简易