C++ mfc做计算器 具体步骤 急!!!!

最好有源代码!!!shenjn@qq.com... 最好有源代码!!!
shenjn@qq.com
展开
 我来答
qinfeng132
2010-07-20 · 超过19用户采纳过TA的回答
知道答主
回答量:54
采纳率:0%
帮助的人:53.9万
展开全部
1.首先做计算器界面类,界面上要用0-9, +,-,*,/,=等(复杂点还可以做的和XP一样的科学计算器)
2.添加计算逻辑,每个按建点下后,在输出栏的显示

我这里有源代码,你如果要请提供邮箱
附部分核心代码:
1.首先做计算器界面类,界面上要用0-9, +,-,*,/,=等(复杂点还可以做的和XP一样的科学计算器)
2.添加计算逻辑,每个按建点下后,在输出栏的显示

我这里有源代码,你如果要请提供邮箱
附部分核心代码:

void CCalDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCalDlg)
DDX_Control(pDX, IDC_BUTTON_9, m_Button9);
DDX_Control(pDX, IDC_BUTTON_8, m_Button8);
DDX_Control(pDX, IDC_BUTTON_7, m_Button7);
DDX_Control(pDX, IDC_BUTTON_6, m_Button6);
DDX_Control(pDX, IDC_BUTTON_5, m_Button5);
DDX_Control(pDX, IDC_BUTTON_4, m_Button4);
DDX_Control(pDX, IDC_BUTTON_3, m_Button3);
DDX_Control(pDX, IDC_BUTTON_27, m_ButtonLog);
DDX_Control(pDX, IDC_BUTTON_26, m_ButtonLn);
DDX_Control(pDX, IDC_BUTTON_25, m_ButtonExp);
DDX_Control(pDX, IDC_BUTTON_24, m_ButtonPow);
DDX_Control(pDX, IDC_BUTTON_23, m_ButtonCub);
DDX_Control(pDX, IDC_BUTTON_22, m_ButtonSqu);
DDX_Control(pDX, IDC_BUTTON_21, m_ButtonTan);
DDX_Control(pDX, IDC_BUTTON_20, m_ButtonCos);
DDX_Control(pDX, IDC_BUTTON_2, m_Button2);
DDX_Control(pDX, IDC_BUTTON_19, m_ButtonSin);
DDX_Control(pDX, IDC_BUTTON_18, m_ButtonReverse);
DDX_Control(pDX, IDC_BUTTON_17, m_ButtonSqrt);
DDX_Control(pDX, IDC_BUTTON_16, m_ButtonClear);
DDX_Control(pDX, IDC_BUTTON_15, m_ButtonDiv);
DDX_Control(pDX, IDC_BUTTON_14, m_ButtonMul);
DDX_Control(pDX, IDC_BUTTON_13, m_ButtonSub);
DDX_Control(pDX, IDC_BUTTON_12, m_ButtonAdd);
DDX_Control(pDX, IDC_BUTTON_11, m_ButtonEqu);
DDX_Control(pDX, IDC_BUTTON_10, m_ButtonPoint);
DDX_Control(pDX, IDC_BUTTON_1, m_Button1);
DDX_Control(pDX, IDC_BUTTON_0, m_Button0);
DDX_Control(pDX, IDC_EDIT1, m_DspEdit);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCalDlg, CDialog)
//{{AFX_MSG_MAP(CCalDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_0, OnButton0)
ON_BN_CLICKED(IDC_BUTTON_1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON_11, OnButtonEqu)
ON_BN_CLICKED(IDC_BUTTON_12, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_10, OnButtonPoint)
ON_BN_CLICKED(IDC_BUTTON_13, OnButtonSub)
ON_BN_CLICKED(IDC_BUTTON_14, OnButtonMul)
ON_BN_CLICKED(IDC_BUTTON_15, OnButtonDiv)
ON_BN_CLICKED(IDC_BUTTON_16, OnButtonClear)
ON_BN_CLICKED(IDC_BUTTON_17, OnButtonSqrt)
ON_BN_CLICKED(IDC_BUTTON_18, OnButtonReverse)
ON_BN_CLICKED(IDC_BUTTON_19, OnButtonSin)
ON_BN_CLICKED(IDC_BUTTON_2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON_20, OnButtonCos)
ON_BN_CLICKED(IDC_BUTTON_21, OnButtonTan)
ON_BN_CLICKED(IDC_BUTTON_22, OnButtonSqu)
ON_BN_CLICKED(IDC_BUTTON_23, OnButtonCub)
ON_BN_CLICKED(IDC_BUTTON_24, OnButtonPow)
ON_BN_CLICKED(IDC_BUTTON_25, OnButtonExp)
ON_BN_CLICKED(IDC_BUTTON_26, OnButtonLn)
ON_BN_CLICKED(IDC_BUTTON_27, OnButtonLog)
ON_BN_CLICKED(IDC_BUTTON_3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON_4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON_5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON_6, OnButton6)
ON_BN_CLICKED(IDC_BUTTON_7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON_8, OnButton8)
ON_BN_CLICKED(IDC_BUTTON_9, OnButton9)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CCalDlg::OnButton0()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"0";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"0";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton1()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"1";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"1";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButtonEqu()
{
// TODO: Add your control notification handler code here
Result();

}

void CCalDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=1;
m_Mark=1;

}

void CCalDlg::OnButtonPoint()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{

if(m_IsCheckPoint!=1&&m_StrBegin!="")
{
m_StrBegin=m_StrBegin+".";
m_IsCheckPoint=1;
}
}
else
{
if(m_IsCheckPoint!=1&&m_StrBegin!="")
{
m_StrEnd=m_StrEnd+".";
m_IsCheckPoint=1;
}
}

}

void CCalDlg::OnButtonSub()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=2;
m_Mark=1;

}

void CCalDlg::OnButtonMul()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=3;
m_Mark=1;

}

void CCalDlg::OnButtonDiv()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=4;
m_Mark=1;

}

void CCalDlg::OnButtonClear()
{
// TODO: Add your control notification handler code here
m_IsCheckPoint=0; //マ﨤ミ。ハオ羃エマツオトア・ヌ

m_StrBegin="";
m_StrEnd="";

m_Mark=0;
m_begin=0.0;
m_end=0.0;
m_bit=0;
m_DspEdit.OnDisplay("0.");
}

void CCalDlg::OnButtonSqrt()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=5;
m_Mark=1;

}

void CCalDlg::OnButtonReverse()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=6;
m_Mark=1;

}

void CCalDlg::OnButtonSin()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=8;
m_Mark=1;

}

void CCalDlg::OnButton2()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"2";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"2";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButtonCos()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=9;
m_Mark=1;

}

void CCalDlg::OnButtonTan()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=10;
m_Mark=1;

}

void CCalDlg::OnButtonSqu()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=11;
m_Mark=1;

}

void CCalDlg::OnButtonCub()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=12;
m_Mark=1;

}

void CCalDlg::OnButtonPow()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=13;
m_Mark=1;

}

void CCalDlg::OnButtonExp()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=14;
m_Mark=1;

}

void CCalDlg::OnButtonLn()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=15;
m_Mark=1;

}

void CCalDlg::OnButtonLog()
{
// TODO: Add your control notification handler code here
m_begin=atof(m_StrBegin);
m_bit=16;
m_Mark=1;

}

void CCalDlg::OnButton3()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"3";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"3";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton4()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"4";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"4";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton5()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"5";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"5";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton6()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"6";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"6";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton7()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"7";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"7";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton8()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"8";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"8";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton9()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"9";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"9";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::Result()
{
m_end=atof(m_StrEnd); //ームハ菠・センラェササホェク。オ飜

switch(m_bit)
{
case 1:
m_end+=m_begin;
break;
case 2:
m_end=m_begin-m_end;
break;
case 3:
m_end=m_begin*m_end;
break;
case 4:
m_end=m_begin/m_end;
break;
case 5:
if(m_end<0)
{
m_DspEdit.OnDisplay("コッハハ菠・゙ミァ!");
break;
}
m_end=sqrt(m_end);
break;
case 6:
if(m_end==0)
{ m_DspEdit.OnDisplay("キヨトクハ菠・゙ミァ!");
break;
}
m_end=1.0/m_end;
break;

case 8:
m_end=sin(m_end);
break;
case 9:
m_end=cos(m_end);
break;
case 10:
m_end=tan(m_end);
break;
case 11:
m_end=m_end*m_end;
break;
case 12:
m_end=m_end*m_end*m_end;
break;
case 13:
m_end=pow(m_begin,m_end);
break;
case 14:
m_end=exp(m_end);
break;
case 15:
if(m_end<=0)
{
m_DspEdit.OnDisplay("コッハハ菠・゙ミァ!");
break;
}
m_end=log(m_end);
break;
case 16:
if(m_end<=0)
{
m_DspEdit.OnDisplay("コッハハ菠・゙ミァ!");
return;
}
m_end=log10(m_end);
break;
}

m_begin=m_end;
m_bit=0;

m_StrEnd="";

gcvt(m_end,15,m_buffer);
m_StrBegin=m_buffer;
m_DspEdit.SetSel(0,-1);
m_DspEdit.ReplaceSel(" ");
m_DspEdit.OnDisplay(m_buffer);
}
Lim
2010-07-20 · 知道合伙人软件行家
Lim
知道合伙人软件行家
采纳数:152 获赞数:1014
资深研发工程师,敏捷教练ScrumMaster

向TA提问 私信TA
展开全部
Hi我,或email:lijiuning(a)gmail.com 我给你发
下面是部分源代码:

void CCalDlg::OnButton0()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"0";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"0";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}

void CCalDlg::OnButton1()
{
// TODO: Add your control notification handler code here
if(m_Mark==0)
{
m_StrBegin=m_StrBegin+"1";
m_DspEdit.OnDisplay(m_StrBegin);
}
else
{
m_StrEnd=m_StrEnd+"1";
m_IsCheckPoint=0;
m_DspEdit.OnDisplay(m_StrEnd);
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友4387504
2010-07-20 · TA获得超过436个赞
知道小有建树答主
回答量:185
采纳率:0%
帮助的人:269万
展开全部
已发送,有教程和源代码,是一本书上的
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友629c242
2010-07-20 · TA获得超过108个赞
知道答主
回答量:150
采纳率:0%
帮助的人:111万
展开全部
我刚做了这个。。不知道用Qt做的啊要???。。。功能均已经实现。。。要可以hi我。。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式