⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 计算器源代码
💻
📖 第 1 页 / 共 4 页
字号:
		btnAtan.ShowWindow(SW_SHOW);
		btnSin.ShowWindow(SW_SHOW);
		btnCos.ShowWindow(SW_SHOW);
		btnTan.ShowWindow(SW_SHOW);
		Group.ShowWindow(SW_SHOW);
		Num16.ShowWindow(SW_SHOW);
		Num10.ShowWindow(SW_SHOW);
		Num8.ShowWindow(SW_SHOW);
		Num2.ShowWindow(SW_SHOW);
		btnA.EnableWindow(FALSE);
		btnB.EnableWindow(FALSE);
		btnC.EnableWindow(FALSE);
		btnD.EnableWindow(FALSE);
		btnE.EnableWindow(FALSE);
		btnF.EnableWindow(FALSE);
	}
}

void CMyDlg::OnHelp() 
{
	// TODO: Add your command handler code here
	ShellExecute(this->m_hWnd,"Open","hh.exe","calc.chm",NULL,SW_SHOW);
}

void CMyDlg::OnAbout() 
{
	// TODO: Add your command handler code here
	CAboutDlg DlgAbout;
	DlgAbout.DoModal();
}

void CMyDlg::OnA() 
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=10;
		ScrText[0]=' ';
		ScrText[1]='A';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='A';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='A';
		}
		ScrNum=ScrNum*16+10;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnB() 
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=11;
		ScrText[0]=' ';
		ScrText[1]='B';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='B';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='B';
		}
		ScrNum=ScrNum*16+11;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnC() 
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=12;
		ScrText[0]=' ';
		ScrText[1]='C';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='C';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='C';
		}
		ScrNum=ScrNum*16+12;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnD() 
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=13;
		ScrText[0]=' ';
		ScrText[1]='D';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='D';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='D';
		}
		ScrNum=ScrNum*16+13;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnE() 
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=14;
		ScrText[0]=' ';
		ScrText[1]='E';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='E';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='E';
		}
		ScrNum=ScrNum*16+14;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnF()
{
	// TODO: Add your control notification handler code here
	ScrLen=Screen.GetWindowTextLength();
	Screen.GetWindowText(ScrText,ScrLen+1);
	if(Flag)
	{
		Flag=0;
		ScrNum=15;
		ScrText[0]=' ';
		ScrText[1]='F';
		ScrText[2]='.';
		ScrText[3]=0;
	}
	else if(ScrLen<30)
	{
		if(ScrNum)
		{
			ScrText[ScrLen-1]='F';
			ScrText[ScrLen]='.';
			ScrText[ScrLen+1]=0;
		}
		else
		{
			ScrText[1]='F';
		}
		ScrNum=ScrNum*16+15;
	}
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnPi()
{
	// TODO: Add your control notification handler code here
	ScrNum=3.1415926535897932384626433833;
	Screen.SetWindowText("3.1415926535897932384626433833");
}

void CMyDlg::OnAnd() 
{
	// TODO: Add your control notification handler code here
	OnEqual();
	Sign=FAND;
	Scr_Num=ScrNum;
}

void CMyDlg::OnNot() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=~(long) ScrNum;
	if(FNum!=FNUM10)
	{
		switch(FNum)
		{
		case FNUM16:
			Num10ToNum16((long) ScrNum,ScrText);
			break;
		case FNUM8:
			Num10ToNum8((long) ScrNum,ScrText);
			break;
		case FNUM2:
			Num10ToNum2((long) ScrNum,ScrText);
		}
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
	}
	else
		DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnOr()
{
	// TODO: Add your control notification handler code here
	OnEqual();
	Sign=FOR;
	Scr_Num=ScrNum;
}

void CMyDlg::OnXor()
{
	// TODO: Add your control notification handler code here
	OnEqual();
	Sign=FXOR;
	Scr_Num=ScrNum;
}

void CMyDlg::OnArccos() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=acos(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnArcsin() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=asin(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnArctan() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=atan(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnCos() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=cos(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnExp() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum>=700)
	{
		Screen.SetWindowText("数值溢出范围。");
		return;
	}
	ScrNum=exp(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnFactorial() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum>170)
	{
		Screen.SetWindowText("数值溢出范围。");
		return;
	}
	double Sum=1;
	for(DWORD i=2;i<=ScrNum;i++)
		Sum*=i;
	ScrNum=Sum;
	if(FNum!=FNUM10)
	{
		switch(FNum)
		{
		case FNUM16:
			Num10ToNum16((long) ScrNum,ScrText);
			break;
		case FNUM8:
			Num10ToNum8((long) ScrNum,ScrText);
			break;
		case FNUM2:
			Num10ToNum2((long) ScrNum,ScrText);
		}
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
	}
	else
		DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnLg() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum<=0)
	{
		Screen.SetWindowText("函数输入无效。");
		return;
	}
	ScrNum=log10(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnLn() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum<=0)
	{
		Screen.SetWindowText("函数输入无效。");
		return;
	}
	ScrNum=log(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnSin() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=sin(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnTan() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	ScrNum=tan(ScrNum);
	DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnXstep2() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum>1.0e+190)
	{
		Screen.SetWindowText("数值溢出范围。");
		return;
	}
	ScrNum*=ScrNum;
	if(FNum!=FNUM10)
	{
		switch(FNum)
		{
		case FNUM16:
			Num10ToNum16((long) ScrNum,ScrText);
			break;
		case FNUM8:
			Num10ToNum8((long) ScrNum,ScrText);
			break;
		case FNUM2:
			Num10ToNum2((long) ScrNum,ScrText);
		}
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
	}
	else
		DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnXstep3() 
{
	// TODO: Add your control notification handler code here
	Flag=1;
	if(ScrNum>1.0e+126)
	{
		Screen.SetWindowText("数值溢出范围。");
		return;
	}
	ScrNum*=ScrNum*ScrNum;
	if(FNum!=FNUM10)
	{
		switch(FNum)
		{
		case FNUM16:
			Num10ToNum16((long) ScrNum,ScrText);
			break;
		case FNUM8:
			Num10ToNum8((long) ScrNum,ScrText);
			break;
		case FNUM2:
			Num10ToNum2((long) ScrNum,ScrText);
		}
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
	}
	else
		DoubleToString(ScrNum,ScrText);
	Screen.SetWindowText(ScrText);
}

void CMyDlg::OnXstepy() 
{
	// TODO: Add your control notification handler code here
	OnEqual();
	Sign=FPOW;
	Scr_Num=ScrNum;
}

void CMyDlg::On10num() 
{
	// TODO: Add your control notification handler code here
	if(FNum!=FNUM10)
	{
		FNum=FNUM10;
		DoubleToString(ScrNum,ScrText);
		Screen.SetWindowText(ScrText);
		btn2.EnableWindow();
		btn3.EnableWindow();
		btn4.EnableWindow();
		btn5.EnableWindow();
		btn6.EnableWindow();
		btn7.EnableWindow();
		btn8.EnableWindow();
		btn9.EnableWindow();
		btnA.EnableWindow(FALSE);
		btnB.EnableWindow(FALSE);
		btnC.EnableWindow(FALSE);
		btnD.EnableWindow(FALSE);
		btnE.EnableWindow(FALSE);
		btnF.EnableWindow(FALSE);
		btnPoint.EnableWindow();
		btnSin.EnableWindow();
		btnCos.EnableWindow();
		btnTan.EnableWindow();
		btnAsin.EnableWindow();
		btnAcos.EnableWindow();
		btnAtan.EnableWindow();
		btnExp.EnableWindow();
		btnLn.EnableWindow();
		btnLg.EnableWindow();
		btnPi.EnableWindow();
		btnSqrt.EnableWindow();
		btnPercent.EnableWindow();
	}
}

void CMyDlg::On16num() 
{
	// TODO: Add your control notification handler code here
	if(FNum!=FNUM16)
	{
		FNum=FNUM16;
		Num10ToNum16((long) ScrNum,ScrText);
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
		Screen.SetWindowText(ScrText);
		btn2.EnableWindow();
		btn3.EnableWindow();
		btn4.EnableWindow();
		btn5.EnableWindow();
		btn6.EnableWindow();
		btn7.EnableWindow();
		btn8.EnableWindow();
		btn9.EnableWindow();
		btnA.EnableWindow();
		btnB.EnableWindow();
		btnC.EnableWindow();
		btnD.EnableWindow();
		btnE.EnableWindow();
		btnF.EnableWindow();
		btnPoint.EnableWindow(FALSE);
		btnSin.EnableWindow(FALSE);
		btnCos.EnableWindow(FALSE);
		btnTan.EnableWindow(FALSE);
		btnAsin.EnableWindow(FALSE);
		btnAcos.EnableWindow(FALSE);
		btnAtan.EnableWindow(FALSE);
		btnExp.EnableWindow(FALSE);
		btnLn.EnableWindow(FALSE);
		btnLg.EnableWindow(FALSE);
		btnPi.EnableWindow(FALSE);
		btnSqrt.EnableWindow(FALSE);
		btnPercent.EnableWindow(FALSE);
	}
}

void CMyDlg::On8num() 
{
	// TODO: Add your control notification handler code here
	if(FNum!=FNUM8)
	{
		FNum=FNUM8;
		Num10ToNum8((long) ScrNum,ScrText);
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
		Screen.SetWindowText(ScrText);
		btn2.EnableWindow();
		btn3.EnableWindow();
		btn4.EnableWindow();
		btn5.EnableWindow();
		btn6.EnableWindow();
		btn7.EnableWindow();
		btn8.EnableWindow(FALSE);
		btn9.EnableWindow(FALSE);
		btnA.EnableWindow(FALSE);
		btnB.EnableWindow(FALSE);
		btnC.EnableWindow(FALSE);
		btnD.EnableWindow(FALSE);
		btnE.EnableWindow(FALSE);
		btnF.EnableWindow(FALSE);
		btn9.EnableWindow(FALSE);
		btn8.EnableWindow(FALSE);
		btnPoint.EnableWindow(FALSE);
		btnSin.EnableWindow(FALSE);
		btnCos.EnableWindow(FALSE);
		btnTan.EnableWindow(FALSE);
		btnAsin.EnableWindow(FALSE);
		btnAcos.EnableWindow(FALSE);
		btnAtan.EnableWindow(FALSE);
		btnExp.EnableWindow(FALSE);
		btnLn.EnableWindow(FALSE);
		btnLg.EnableWindow(FALSE);
		btnPi.EnableWindow(FALSE);
		btnSqrt.EnableWindow(FALSE);
		btnPercent.EnableWindow(FALSE);
	}
}

void CMyDlg::On2num() 
{
	// TODO: Add your control notification handler code here
	if(FNum!=FNUM2)
	{
		FNum=FNUM2;
		Num10ToNum2((long) ScrNum,ScrText);
		ScrLen=(char) LengthOfString(ScrText);
		ScrText[ScrLen]='.';
		ScrText[ScrLen+1]=0;
		Screen.SetWindowText(ScrText);
		btn2.EnableWindow(FALSE);
		btn3.EnableWindow(FALSE);
		btn4.EnableWindow(FALSE);
		btn5.EnableWindow(FALSE);
		btn6.EnableWindow(FALSE);
		btn7.EnableWindow(FALSE);
		btn8.EnableWindow(FALSE);
		btn9.EnableWindow(FALSE);
		btnA.EnableWindow(FALSE);
		btnB.EnableWindow(FALSE);
		btnC.EnableWindow(FALSE);
		btnD.EnableWindow(FALSE);
		btnE.EnableWindow(FALSE);
		btnF.EnableWindow(FALSE);
		btn9.EnableWindow(FALSE);
		btn8.EnableWindow(FALSE);
		btn7.EnableWindow(FALSE);
		btn6.EnableWindow(FALSE);
		btn5.EnableWindow(FALSE);
		btn4.EnableWindow(FALSE);
		btn3.EnableWindow(FALSE);
		btn2.EnableWindow(FALSE);
		btnPoint.EnableWindow(FALSE);
		btnSin.EnableWindow(FALSE);
		btnCos.EnableWindow(FALSE);
		btnTan.EnableWindow(FALSE);
		btnAsin.EnableWindow(FALSE);
		btnAcos.EnableWindow(FALSE);
		btnAtan.EnableWindow(FALSE);
		btnExp.EnableWindow(FALSE);
		btnLn.EnableWindow(FALSE);
		btnLg.EnableWindow(FALSE);
		btnPi.EnableWindow(FALSE);
		btnSqrt.EnableWindow(FALSE);
		btnPercent.EnableWindow(FALSE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -