📄 kxdlg.cpp
字号:
// TODO: Add your control notification handler code here
m_operator=OpXor;
m_operavail=FALSE;
run( );// pushfh( );
}
void CKXdlg::OnNot()
{
// TODO: Add your control notification handler code here
int a;
a=(int)m_operand;
m_operand=~a;
m_operavail=FALSE;
m_accum=m_operand;
updisp( );
}
void CKXdlg::OnInt()
{
// TODO: Add your control notification handler code here
if(m_jinzhi==1)
{ m_operand=(int)m_operand;
m_operavail=FALSE;
m_accum=m_operand;
updisp( );
}
}
void CKXdlg::OnRadio1()
{
// TODO: Add your control notification handler code here
bool state=TRUE;
UpdateData( );
enable16(state);
enable10(state);
enablefunc(FALSE);
settext( );
disp16( );
/* CString str1;
int lVal = (m_operavail) ? (int)m_operand :(int)m_accum;
str1.Format("%x",lVal);
CEdit* pedit=(CEdit *)GetDlgItem(IDC_EDITKX);
pedit->SetWindowText(str1);
*/ m_operavail=FALSE;
m_accum=m_operand;}
void CKXdlg::settext()
{
if (m_jinzhi!=1)
{ GetDlgItem(IDC_RADIO5)->SetWindowText("双字");
GetDlgItem(IDC_RADIO6)->SetWindowText("字");
GetDlgItem(IDC_RADIO7)->SetWindowText("字节");
m_dushu=0;
UpdateData(FALSE);}
else if(m_jinzhi==1)
{ GetDlgItem(IDC_RADIO5)->SetWindowText("度数");
GetDlgItem(IDC_RADIO6)->SetWindowText("弧度");
GetDlgItem(IDC_RADIO7)->SetWindowText("梯度");
m_dushu=0;
UpdateData(FALSE);
}}
void CKXdlg::OnRadio2()
{
// TODO: Add your control notification handler code here
UpdateData( );
enable16(FALSE);
enable10(TRUE);
enablefunc(TRUE);
settext( );
CString str1;
double lVal = (m_operavail) ? m_operand :m_accum;
str1.Format("%f",lVal);
int i=str1.GetLength( );
while(str1.GetAt(i-1)=='0')
{
str1.Delete(i-1,1);
i-=1;
}
CEdit* pedit=(CEdit *)GetDlgItem(IDC_EDITKX);
pedit->SetWindowText(str1);
m_operavail=FALSE;
m_accum=m_operand;
}
void CKXdlg::OnRadio3()
{
// TODO: Add your control notification handler code here
UpdateData( );
enable16(FALSE);
enable10(TRUE);
enable8(FALSE);
enablefunc(FALSE);
settext( );
disp8( );
/* CString str1;
int lVal = (m_operavail) ? (int)m_operand :(int)m_accum;
str1.Format("%o",lVal);
CEdit* pedit=(CEdit *)GetDlgItem(IDC_EDITKX);
pedit->SetWindowText(str1);
*/
m_operavail=FALSE;
m_accum=m_operand;}
void CKXdlg::OnRadio4()
{
// TODO: Add your control notification handler code here
UpdateData( );
enable16(FALSE);
enable2(FALSE);
enablefunc(FALSE);
settext( );
disp2( );
m_operavail=FALSE;
m_accum=m_operand;
}
void CKXdlg::OnRadio6()
{
// TODO: Add your control notification handler code here
if(m_jinzhi==1)
m_dushu=1;
UpdateData( );
updisp( );
m_accum=m_operand;
m_operavail=FALSE;}
void CKXdlg::OnRadio5()
{
// TODO: Add your control notification handler code here
if(m_jinzhi==1)
m_dushu=0;
UpdateData( );
updisp( );
m_accum=m_operand;
m_operavail=FALSE;
}
void CKXdlg::OnRadio7()
{
// TODO: Add your control notification handler code here
if(m_jinzhi==1)
m_dushu=2;
UpdateData( );
updisp( );
m_accum=m_operand;
m_operavail=FALSE;}
void CKXdlg::setoperand(double value)
{
m_operavail=TRUE;
m_operand=value;
}
void CKXdlg::OnButtonpoint()
{
// TODO: Add your control notification handler code here
if (point==0)
point=1;
m_operavail=TRUE;
}
void CKXdlg::OnOK()
{
// TODO: Add extra validation here
CEdit* pedit=(CEdit *)GetDlgItem(IDC_EDITKX);
pedit->SetWindowText("0");
m_operavail=FALSE;
// CDialog::OnOK();
}
void CKXdlg::OnCC()
{
// TODO: Add your control notification handler code here
onclearkx( );
if (m_jinzhi==0)
{UpdateData(FALSE); OnRadio1( );}
if (m_jinzhi==1)
{ UpdateData(FALSE); OnRadio2( );}
if (m_jinzhi==2)
{ UpdateData(FALSE); OnRadio3( );}
if (m_jinzhi==3)
{ UpdateData(FALSE); OnRadio4( );}
if(g_pmodless)
enablecount(TRUE);
clears( );
clearp( );}
void CKXdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CKXdlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
void CKXdlg::pushfh() //压入堆栈
{
if ((signum==0)||(m_operator==OpLeft)||((m_operator>opersign[signum-1])&&signum))
{ if( m_operator==OpLeft)
opersign[signum++]=m_operator;
else
{opersign[signum++]=m_operator;
opernum[number++]=m_operand;
}
}
else
{ while((signum)&& (m_operator<=opersign[signum-1]))
{
if(opersign[signum-1]==OpMultiply)
{ m_operand=m_operand*opernum[--number];
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpAdd)
{ m_operand=m_operand+opernum[--number];
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpDivide)
{ m_operand=opernum[--number]/m_operand;
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpSubtract)
{ m_operand=opernum[--number]-m_operand;
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpPow)
{ if (m_inv)
{m_operand=pow(opernum[--number],1.0/m_operand);
m_inv=FALSE;
UpdateData(FALSE);}
else
m_operand=pow(opernum[--number],m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpAnd)
{ m_operand=((int)opernum[--number])&((int)m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpXor)
{ m_operand=((int)opernum[--number])^((int)m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}}
if(opersign[signum-1]==OpOr)
{m_operand=((int)opernum[--number])|((int)m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}}
if(opersign[signum-1]==OpLsh)
{m_operand=((int)opernum[--number])<<((int)m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}
}
if(opersign[signum-1]==OpMod)
{ m_operand=((int)opernum[--number])%((int)m_operand);
if(m_operator==OpRight)
{signum=signum-2; break;}}
signum--;
opernum[number]=m_operand; }
if(m_operator==OpNone)
{ signum=0;number=0;}
else
if (m_operator==OpRight);
else
{opersign[signum++]=m_operator;
opernum[number++]=m_operand;}
m_accum=m_operand;
updisp( );}
}
BOOL CKXdlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (m_hAccel != NULL && TranslateAccelerator(m_hWnd, m_hAccel, pMsg))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
void CKXdlg::OnSin()
{
// TODO: Add your control notification handler code here
double qq;
qq=m_operand;
if(m_jinzhi==1)
{
if(m_dushu==0)
{ if (!m_inv&&!m_hyp) qq=sin(qq/180*pi);
else if(!m_hyp&&m_inv) { qq=asin(qq)*180/pi;m_inv=FALSE;UpdateData(FALSE);}
}
else
if(m_dushu==1)
{ if (!m_inv&&!m_hyp) qq=sin(qq);
else if(!m_hyp&&m_inv) qq=asin(qq); m_inv=FALSE;UpdateData(FALSE);}
if (m_hyp)
{ qq=sinh(qq); m_hyp=FALSE;UpdateData(FALSE);}
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
}
void CKXdlg::OnCos()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
//else
//qq=s.pop( );
if(m_jinzhi==1)
{if(m_dushu==0)
{ if (!m_inv&&!m_hyp) qq=cos(qq/180*pi);
else if(!m_hyp&&m_inv) { qq=acos(qq)*180/pi;m_inv=FALSE;UpdateData(FALSE);}
}
else
if(m_dushu==1)
{ if (!m_inv&&!m_hyp) qq=cos(qq);
else if(!m_hyp&&m_inv) qq=acos(qq); m_inv=FALSE;UpdateData(FALSE);}
if (m_hyp)
{ qq=cosh(qq); m_hyp=FALSE;UpdateData(FALSE);}
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
}
void CKXdlg::OnTan()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
// else qq=s.pop( );
if(m_jinzhi==1)
{if(m_dushu==0)
{ if (!m_inv&&!m_hyp) qq=tan(qq/180*pi);
else if(!m_hyp&&m_inv) { qq=atan(qq)*180/pi;m_inv=FALSE;UpdateData(FALSE);}
}
else
if(m_dushu==1)
{ if (!m_inv&&!m_hyp) qq=tan(qq);
else if(!m_hyp&&m_inv) qq=atan(qq); m_inv=FALSE;UpdateData(FALSE);}
if (m_hyp)
{ qq=tanh(qq); m_hyp=FALSE;UpdateData(FALSE);}
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
}
void CKXdlg::OnIn()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
// else qq=s.pop( );
if(m_inv)
{qq=exp(qq);m_inv=FALSE;UpdateData(FALSE);} //LOG的反函数
else
qq=log(qq);
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
void CKXdlg::OnLog()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
//else qq=s.pop( );
if(m_inv)
{qq=pow(10,qq); m_inv=FALSE;UpdateData(FALSE);}
// LOG10的反函数
else
qq=log10(qq);
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
void CKXdlg::OnFactor()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
// else qq=s.pop( );
int i;
long fa=1;
for(i=1;i<=qq;i++)
fa*=i;
qq=fa;
m_operavail=FALSE;
m_accum=m_operand=qq;
// s.push(qq);
updisp( );
}
void CKXdlg::OnDaoshux()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
// else qq=s.pop( );
if(qq)
{
qq=1/qq;
m_operavail=FALSE;
m_accum=m_operand=qq;
//s.push(qq);
updisp( );
}
}
void CKXdlg::Onzhengfu()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
//else qq=s.pop( );
qq=(-1)*qq;
m_operavail=FALSE;
m_accum=m_operand=qq;
if(m_str.GetAt(0)=='-') m_str.Delete(0,1);
else
m_str.Insert(0,'-');
UpdateData(FALSE);
// s.push(qq);
//updisp( );
}
void CKXdlg::OnFe()
{
// TODO: Add your control notification handler code here
fe=!fe;
updisp( );
}
void CKXdlg::OnExp()
{
// TODO: Add your control notification handler code here
if(m_jinzhi==1)
{ CString str;
str.Format(_T("%f"),m_operand);
int i=str.GetLength( );
while(str.GetAt(i-1)=='0')
{
str.Delete(i-1,1);
i-=1;
}
str.Format("%s%s",str,"e+0");
CEdit* pedit=(CEdit *)GetDlgItem(IDC_EDITKX);
pedit->SetWindowText(str);
m_operavail=FALSE;
}
}
void CKXdlg::OnX3()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
//else qq=s.pop( );
if(m_inv)
{qq=pow(qq,1.0/3);m_inv=FALSE;UpdateData(FALSE);}//三次方根
else
qq=pow(qq,3);
//s.push(qq);
m_operavail=FALSE;
m_accum=m_operand=qq;
updisp( );
}
void CKXdlg::OnX2()
{
// TODO: Add your control notification handler code here
double qq;
//if(s.stackempty( ))
qq=m_operand;
//else qq=s.pop( );
if(m_inv)
{qq=pow(qq,1.0/2);m_inv=FALSE;UpdateData(FALSE);}//二次方根
else
qq=pow(qq,2);
//s.push(qq);
m_operavail=FALSE;
m_accum=m_operand=qq;
updisp( );
}
void CKXdlg::OnXy()
{
// TODO: Add your control notification handler code here
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -