BOOL CCalc_mfcDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_strNext =_T(' ');
m_strCur =_T(' ');
m_strPre =_T(' ');
m_dNext=0;
m_dCur=0;
m_dPre=0;
m_nDotSign=0;
m_nDotNo=0;
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCalc_mfcDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCalc_mfcDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCalc_mfcDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCalc_mfcDlg::OnButton10()
{
// TODO: Add your control notification handler code here
SetNum(0)
}
void CCalc_mfcDlg::OnButton2()
{
// TODO: Add your control notification handler code here
SetNum(2)
}
void CCalc_mfcDlg::OnButton1()
{
// TODO: Add your control notification handler code here
SetNum(1)
}
void CCalc_mfcDlg::OnButton3()
{
// TODO: Add your control notification handler code here
SetNum(3)
}
void CCalc_mfcDlg::OnButton4()
{
// TODO: Add your control notification handler code here
SetNum(4)
}
void CCalc_mfcDlg::OnButton5()
{
// TODO: Add your control notification handler code here
SetNum(5)
}
void CCalc_mfcDlg::OnButton20()
{
// TODO: Add your control notification handler code here
m_strNext=_T("");
CString m_strCur=_T("");
CString m_strPre=_T("");
double m_dNext=0;
double m_dCur=0;
double m_dPre=0;
int m_nDotSign=0;
int m_nDotNo=0;
}
void CCalc_mfcDlg::OnButton6()
{
// TODO: Add your control notification handler code here
SetNum(6)
}
void CCalc_mfcDlg::OnButton7()
{
// TODO: Add your control notification handler code here
SetNum(7)
}
void CCalc_mfcDlg::OnButton8()
{
// TODO: Add your control notification handler code here
SetNum(8)
}
void CCalc_mfcDlg::OnButton9()
{
// TODO: Add your control notification handler code here
SetNum(9)
}
void CCalc_mfcDlg::OnButton19()
{
// TODO: Add your control notification handler code here
m-nDotSign==1;
m-nDotNo=1;
}
void CCalc_mfcDlg::OnButton11()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{
m_dPre=m_dCur;
m_strPre="+";
m_strCur=m_strPre;
}
else
{process();
m_strPre="+";
m_strCur=m_strPre;
}
m_dNum=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNO=0;
UpdataData(false);
}
void CCalc_mfcDlg::OnButton12()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{
m_dPre=m_dCur;
m_strPre="-";
m_strCur=m_strPre;
}
else
{process();
m_strPre="-";
m_strCur=m_strPre;
}
m_dNum=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNO=0;
UpdataData(false);
}
void CCalc_mfcDlg::OnButton13()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{
m_dPre=m_dCur;
m_strPre="*";
m_strCur=m_strPre;
}
else
{process();
m_strPre="*";
m_strCur=m_strPre;
}
m_dNum=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNO=0;
UpdataData(false);
}
void CCalc_mfcDlg::OnButton14()
{
// TODO: Add your control notification handler code here
if(m_dPre==0)
{
m_dPre=m_dCur;
m_strPre="/";
m_strCur=m_strPre;
}
else
{process();
m_strPre="/";
m_strCur=m_strPre;
}
m_dNum=m_dPre;
m_dCur=0;
m_nDotSign=0;
m_nDotNO=0;
UpdataData(false);
}
void CCalc_mfcDlg::OnButton15()
{
// TODO: Add your control notification handler code here exp function
}
void CCalc_mfcDlg::OnButton16()
{
// TODO: Add your control notification handler code here mod function
}
void CCalc_mfcDlg::OnButton17()
{
// TODO: Add your control notification handler code here log function
}
void CCalc_mfcDlg::OnButton18()
{
// TODO: Add your control notification handler code here 10 function
}
void CCalcDlg::process()
{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)m_dCur=1;
m_strPre/=m_dCur;
}
}