Add your control notification handler code here
if(m_dPre==0)
{ m_dPre=m_dCur;
m_strPre="-";
m_strCur=m_strPre;
}
else
{ ifelse();
m_strPre="-";
m_strCur=m_strPre;
}
m_shurushuju=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNo=0;
UpdateData(false);
}
void Cjiandanjisuan::OnButt13()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{ m_dPre=m_dCur;
m_strPre="*";
m_strCur=m_strPre;
}
else
{ ifelse();
m_strPre="*";
m_strCur=m_strPre;
}
m_shurushuju=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNo=0;
UpdateData(false);
}
void Cjiandanjisuan::OnButt14()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{ m_dPre=m_dCur;
m_strPre="/";
m_strCur=m_strPre;
}
else
{ ifelse();
m_strPre="/";
m_strCur=m_strPre;
}
m_shurushuju=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNo=0;
UpdateData(false);
}
void Cjiandanjisuan::OnButt15()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{ m_dPre=m_dCur;
m_strPre="=";
m_strCur=m_strPre;
}
else
{ ifelse();
m_strPre="=";
m_strCur=m_strPre;
}
m_shurushuju=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNo=0;
UpdateData(false);
}
void Cjiandanjisuan::SetNum(int i)
{
if(m_strCur=="")
{
if(m_nDotSign==1)
{ m_dCur=m_dCur+i/(pow(10,m_nDotNo));
m_nDotNo++;
}
else m_dCur=m_dCur*10+i;
}
else
{ m_dCur=0;
if(m_nDotSign==1)
{ m_dCur=m_dCur+i/10;
m_nDotNo++;
}
else m_dCur=m_dCur*10+i;
}
m_shurushuju=m_dCur;
UpdateData(false);
m_strCur=_T("");
}
void Cjiandanjisuan::ifelse()
{
if(m_strPre=="+") m_dPre+=m_dCur;
if(m_strPre=="-") m_dPre-=m_dCur;
if(m_strPre=="*") m_dPre*=m_dCur;
if(m_strPre=="/")
{
if(m_dCur==0)
{
MessageBox("除数不能为0,请重新输入
45B62_2E80_4A0A_9B00_937F555FFBFA__INCLUDED_
#include "math.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// jiandanjisuan.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// Cjiandanjisuan dialog
class Cjiandanjisuan : public CDialog
{
// Construction
void ifelse();
int m_nDotSign;
int m_nDotNo;
void SetNum(int);
CString m_strNext;
CString m_strPre;
CString m_strCur;
double m_dNext;
double m_dCur;
double m_dPre;
public:
Cjiandanjisuan(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Cjiandanjisuan)
enum { IDD = IDD_DIALOG4 };
double m_shurushuju;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Cjiandanjisuan)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Cjiandanjisuan)
afx_msg void OnButt1();
afx_msg void OnButt2();
afx_msg void OnButt3();
afx_msg void OnButt4();
afx_msg void OnButt5();
afx_msg void OnButt6();
afx_msg void OnButt7();
afx_msg void OnButt8();
afx_msg void OnButt9();
afx_msg void OnButt11();
afx_msg void OnButt12();
afx_msg void OnButt13();
afx_msg void OnButt14();
afx_msg void OnButt15();
afx_msg void OnButt16();
virtual BOOL OnInitDialog();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined 下载本文