void operator += (LPCSTR str)
{
CString CurrText;
GetWindowText (CurrText);
if(CurrText!="0")
CurrText += str;
else
CurrText = str;
SetWindowText (CurrText);
}
void CCalciDlg::OnBnClickedCbutton0()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "0";
}
void CCalciDlg::OnBnClickedCbutton1()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "1";
}
void CCalciDlg::OnBnClickedCbutton2()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "2";
}
void CCalciDlg::OnBnClickedCbutton3()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "3";
}
void CCalciDlg::OnBnClickedCbutton4()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "4";
}
void CCalciDlg::OnBnClickedCbutton5()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "5";
}
void CCalciDlg::OnBnClickedCbutton6()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "6";
}
void CCalciDlg::OnBnClickedCbutton7()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "7";
}
void CCalciDlg::OnBnClickedCbutton8()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "8";
}
void CCalciDlg::OnBnClickedCbutton9()
{
if(eqflg==TRUE)
{
SetDlgItemText(IDCRESULT,_T("0"));
eqflg=FALSE;
}
resu += "9";
}
void CCalciDlg::OnBnClickedCbuttonpoint()
{
CString msg;
GetDlgItemText(IDCRESULT,msg);
if(flg==TRUE)
{
msg=msg+'.';
SetDlgItemText(IDCRESULT,msg);
flg=FALSE;
}
pctrl.EnableWindow(FALSE);
}
void CCalciDlg::OnBnClickedCbuttondiv()
{
num=0;
opflg=4;
UpdateData(TRUE);
num=num1;
SetDlgItemText(IDCRESULT,_T("0"));
}
void CCalciDlg::OnBnClickedCbuttonmul()
{
num=0;
opflg=3;
UpdateData(TRUE);
num=num1;
SetDlgItemText(IDCRESULT,_T("0"));
}
void CCalciDlg::OnBnClickedCbuttonplus()
{
num=0;
opflg=1;
UpdateData(TRUE);
num=num1;
SetDlgItemText(IDCRESULT,_T("0"));
}
void CCalciDlg::OnBnClickedCbuttonminus()
{
num=0;
opflg=2;
UpdateData(TRUE);
num=num1;
SetDlgItemText(IDCRESULT,_T("0"));
}
void CCalciDlg::OnBnClickedCbuttonequal()
{
eqflg=TRUE;
if(num1!=0)
{
UpdateData(TRUE);
switch(opflg)
{
case 1:
num=num+num1;
break;
case 2:
num=num-num1;
break;
case 3:
num=num*num1;
break;
case 4:
num=num/num1;
break;
case 0:
AfxMessageBox(_T("Please Select The Operation"),MB_OK);
break;
}
CString str;
str.Format(_T("%.2f"), num);
SetDlgItemText(IDCRESULT,str);
resu.SetSel(0,-1);
}
else
{
AfxMessageBox(_T("Enter The Second Value"),MB_OK);
}
}