?? 我的計(jì)算器 dlg.cpp
字號(hào):
m_TableFlag=TRUE;
m_symbol='-';
GetDlgItem(IDC_EDIT3)->EnableWindow(SW_SHOW);
m_Number2.ShowWindow(SW_SHOW);
m_Number1.GetWindowText (m_str1,20);
int i=0;
while(m_str1[i])
{
if(m_str1[i]<'0'||m_str1[i]>'9')
{
if(!Fflag)
{
MessageBox("你輸入的整數(shù)中可能出現(xiàn)了非0——9的非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
else if(m_str1[i]!='.')
{
MessageBox("你輸入的數(shù)據(jù)中有非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
}
i++;
}
m_data1=atof((LPCTSTR)m_str1);
m_Symbol.SetWindowText("-");
UpdateData(FALSE);
}
void CMyDlg::OnMulti()
{
// TODO: Add your control notification handler code here
m_TableFlag=TRUE;
m_symbol='*';
GetDlgItem(IDC_EDIT3)->EnableWindow(SW_SHOW);
m_Number2.ShowWindow(SW_SHOW);
m_Number1.GetWindowText (m_str1,20);
int i=0;
while(m_str1[i])
{
if(m_str1[i]<'0'||m_str1[i]>'9')
{
if(!Fflag)
{
MessageBox("你輸入的整數(shù)中可能出現(xiàn)了非0——9的非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
else if(m_str1[i]!='.')
{
MessageBox("你輸入的數(shù)據(jù)中有非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
}
i++;
}
m_data1=atof((LPCTSTR)m_str1);
m_Symbol.SetWindowText("*");
UpdateData(FALSE);
}
void CMyDlg::OnDivid()
{
// TODO: Add your control notification handler code here
m_TableFlag=TRUE;
m_symbol='/';
GetDlgItem(IDC_EDIT3)->EnableWindow(SW_SHOW);
m_Number2.ShowWindow(SW_SHOW);
m_Number1.GetWindowText (m_str1,20);
int i=0;
while(m_str1[i])
{
if(m_str1[i]<'0'||m_str1[i]>'9')
{
if(!Fflag)
{
MessageBox("你輸入的整數(shù)中可能出現(xiàn)了非0——9的非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
else if(m_str1[i]!='.')
{
MessageBox("你輸入的數(shù)據(jù)中有非法數(shù)據(jù),請(qǐng)重新鍵入你的數(shù)據(jù)!\t","錯(cuò)誤提示", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
m_TableFlag=FALSE;
return;
}
}
i++;
}
m_data1=atof((LPCTSTR)m_str1);
m_Symbol.SetWindowText("/");
UpdateData(FALSE);
}
////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//設(shè)置四個(gè)功能鍵:退出,刪除,清零,繼續(xù)的映射函數(shù)
//退出
void CMyDlg::OnOK()
{
// TODO: Add extra validation here
if(MessageBox("你真的要退出嗎!\t","錯(cuò)誤提示", MB_ICONQUESTION|MB_OKCANCEL|MB_DEFBUTTON2)==IDOK)
{
MessageBox("謝謝使用!\t","致謝框", MB_ICONWARNING|MB_OK|MB_DEFBUTTON1);
CDialog::OnOK();
}
}
///清除
void CMyDlg::OnClear()
{
// TODO: Add your control notification handler code here
m_result=0;
m_data1=0;
m_data2=0;
memset(m_str1,0,sizeof(m_str1));
memset(m_str2,0,sizeof(m_str2));
m_TableFlag=FALSE;
m_Number1.SetSel (0,-1);
m_Number1.ReplaceSel ("");
m_Number2.SetSel (0,-1);
m_Number2.ReplaceSel ("");
m_Symbol.SetSel (0,-1);
m_Symbol.ReplaceSel ("");
m_Result="";
UpdateData(FALSE);
}
//刪除
void CMyDlg::OnDelete()
{
// TODO: Add your control notification handler code here
if(m_DeleteFlag)
{
if(!m_TableFlag)
{
int i=0;
m_Number1.GetWindowText(m_str1,20);
while(m_str1[i])
i++;
m_str1[i-1]=NULL;
m_Number1.SetWindowText(m_str1);
}
else
{
int i=0;
m_Number2.GetWindowText(m_str2,20);
while(m_str2[i])
i++;
m_str2[i-1]=NULL;
m_Number2.SetWindowText(m_str2);
}
}
else
{
memset(m_str1,0,sizeof(m_str1));
m_Number1.SetSel(0,-1);
m_Number1.ReplaceSel("");
}
UpdateData(FALSE);
}
//繼續(xù)
void CMyDlg::OnContinue()
{
// TODO: Add your control notification handler code here
memset(m_str2,0,sizeof(m_str2));
m_TableFlag=FALSE;
int i=0;
while(m_str1[i])
i++;
if(m_str1[i]=='.')
if(Fflag)
m_str1[i-1]=NULL;
m_Number1.SetWindowText(m_str1);
m_Number2.SetSel (0,-1);
m_Number2.ReplaceSel ("");
m_Symbol.SetSel (0,-1);
m_Symbol.ReplaceSel ("");
m_Result="";
UpdateData(FALSE);
}
void CMyDlg::OnQuitKeyItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊這個(gè)鍵退出計(jì)算器!\n\n明白嗎?","退出鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// 刪除標(biāo)志的設(shè)置
void CMyDlg::OnDeleteSet()
{
// TODO: Add your command handler code here
m_DeleteFlag=TRUE;
m_DelType.SetSel(0,-1);
m_DelType.ReplaceSel("每次刪去一個(gè)數(shù)字");
UpdateData(FALSE);
}
void CMyDlg::OnDeleteChange()
{
// TODO: Add your command handler code here
m_DeleteFlag=FALSE;
m_DelType.SetSel(0,-1);
m_DelType.ReplaceSel("每次刪去整個(gè)數(shù)據(jù)");
UpdateData(FALSE);
}
//////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
//計(jì)算方式標(biāo)志的設(shè)置
void CMyDlg::OnCalInit()
{
// TODO: Add your command handler code here
m_CommonCalculate=TRUE;
m_CalType.SetSel(0,-1);
m_CalType.ReplaceSel("日常運(yùn)算");
UpdateData(FALSE);
GetDlgItem(IDC_EDIT3)->EnableWindow(SW_SHOW);
m_Number2.ShowWindow(SW_SHOW);
}
void CMyDlg::OnCalChange()
{
// TODO: Add your command handler code here
m_CommonCalculate=FALSE;
m_CalType.SetSel(0,-1);
m_CalType.ReplaceSel("科學(xué)運(yùn)算");
UpdateData(FALSE);
m_Number2.SetSel (0,-1);
m_Number2.ReplaceSel ("");
m_Number2.EnableWindow(FALSE);
UpdateData(FALSE);
}
//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//科學(xué)運(yùn)算的映射函數(shù)的處理
void CMyDlg::Onln()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate&&MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=log(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其ln值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
void CMyDlg::Onlog()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate)
{
if(MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=log10(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其lg值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
void CMyDlg::OnSin()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate)
{
if(MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=sin(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其sin值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
void CMyDlg::OnCos()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate)
{
if(MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=cos(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其cos值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
void CMyDlg::OnTan()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate)
{
if(MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=tan(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其tan值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
void CMyDlg::OnSqrt()
{
// TODO: Add your control notification handler code here
if( m_CommonCalculate)
{
if(MessageBox("對(duì)不起,在日常運(yùn)算里面不能進(jìn)行科學(xué)運(yùn)算!要改變你的運(yùn)算類(lèi)型嗎?","錯(cuò)誤提示",\
MB_ICONINFORMATION|MB_YESNO|MB_DEFBUTTON2)==IDNO)
{
MessageBox("請(qǐng)重新?lián)羧肽愕倪\(yùn)算符!\t","運(yùn)算符重新?lián)羧胩崾?quot;,\
MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
return;
}
}
m_Number2.EnableWindow(FALSE);
m_result=atof((LPCTSTR)m_str1);
m_result=sqrt(m_result);
_gcvt(m_result,20,m_str1);
m_Symbol.SetWindowText ("求其平方根值為");
int i=0;
while(m_str1[i])
i++;
if(Fflag)
{
m_str1[i]='0';
m_str1[i+1]=NULL;
}
else
m_str1[i-1]=NULL;
m_Result=(LPCTSTR)m_str1;
UpdateData(FALSE);
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//浮點(diǎn)標(biāo)志設(shè)置的映射處理函數(shù)
void CMyDlg::OnFflagSet()
{
// TODO: Add your command handler code here
Fflag=TRUE;
m_DataType.SetSel(0,-1);
m_DataType.ReplaceSel("浮點(diǎn)數(shù)據(jù)");
UpdateData(FALSE);
}
void CMyDlg::OnFflagChange()
{
// TODO: Add your command handler code here
Fflag=FALSE;
m_DataType.SetSel(0,-1);
m_DataType.ReplaceSel("整形數(shù)據(jù)");
UpdateData(FALSE);
}
/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//幫助部分的所有功能提示
void CMyDlg::OnNumberIntro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊0—9這十個(gè)數(shù)字來(lái)進(jìn)行數(shù)據(jù)的鍵入!\n\n明白嗎?","數(shù)字鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnDailSymbolItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊+或者-或者*或者/這幾個(gè)日常運(yùn)算符來(lái)進(jìn)行運(yùn)算的選擇!\n\n明白嗎?","日常運(yùn)算符鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnComSymbolItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊這幾個(gè)科學(xué)運(yùn)算符來(lái)進(jìn)行運(yùn)算的選擇!他們只在設(shè)置了運(yùn)算類(lèi)型為科學(xué)運(yùn)算時(shí)才可用!\n\n明白嗎?","科學(xué)運(yùn)算符鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnProcessItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊等號(hào)來(lái)進(jìn)行運(yùn)算!\n\n明白嗎?","等號(hào)鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnContinueKeyItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊這幾個(gè)鍵來(lái)進(jìn)行是否繼續(xù)運(yùn)算的選擇!\n\n你可以在此基礎(chǔ)上繼續(xù)輸入新的數(shù)據(jù),也可直接進(jìn)行運(yùn)算\n\n明白嗎?","繼續(xù)鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnClearKeyItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊這個(gè)鍵來(lái)進(jìn)行清零操作!他將計(jì)算器上所顯示的所有數(shù)據(jù)都清除掉!\n\n明白嗎?","清零鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnDeleKeyItro()
{
// TODO: Add your command handler code here
MessageBox("點(diǎn)擊這幾個(gè)科學(xué)運(yùn)算符來(lái)進(jìn)行刪除操作!\n\n\n\n他有兩種模式,第一種是每次只刪去一個(gè)數(shù)字,這是系統(tǒng)默認(rèn)的;\n\n第二種是每次將你輸入的整個(gè)數(shù)據(jù)都刪去!\n\n明白嗎?","科學(xué)運(yùn)算符鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
void CMyDlg::OnInputItro()
{
// TODO: Add your command handler code here
MessageBox("本計(jì)算器可以支持完全的鼠標(biāo)點(diǎn)擊輸入,對(duì)于數(shù)據(jù)的輸入也可以采用鍵盤(pán)!\n\n明白嗎?","退出鍵介紹",MB_ICONQUESTION|MB_OK|MB_DEFBUTTON1);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -