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

📄 computerdlg.cpp

📁 关于移动通信工程常用的计算工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	{
	UpdateData(true);
	if(m_dot==false)
	{
	if(m_show=="0."||m_finish==true)
	m_show="3.";
	else
	{
	m_show=m_show.Left(m_show.GetLength()-1)+"3"+".";
	}
	}
	else m_show+="3";
	UpdateData(false);
	}
else if(m_counting==true)
	{
	m_counting=false;
	UpdateData(true);
	if(m_dot==false)
	m_show="3.";
	else m_show+="3";
	UpdateData(false);
	}
if(m_finish==true) m_finish=false;
}

void CComputerDlg::OnButton10() 
{
	// TODO: Add your control notification handler code here
	if(m_valid==true&&m_counting==false)
	{
	UpdateData(true);
	if(m_dot==false)
	{
	if(m_show=="0."||m_finish==true)
	m_show="0.";
	else
	{
	m_show=m_show.Left(m_show.GetLength()-1)+"0"+".";
	}
	}
	else m_show+="0";
	UpdateData(false);
	}
else if(m_counting==true)
	{
	m_counting=false;
	UpdateData(true);
	if(m_dot==false)
	m_show="0.";
	else m_show+="0";
	UpdateData(false);
	}
if(m_finish==true) m_finish=false;
}

void CComputerDlg::OnButton12() 
{
	// TODO: Add your control notification handler code here
   if(m_valid==true&&m_counting==false)
	{
	m_dot=true;
	}
else if(m_counting==true)
	{
	m_counting=false;
	UpdateData(true);
	m_show="0.";m_dot=true;
	UpdateData(false);
	}
}

void CComputerDlg::OnButton11() 
{
	// TODO: Add your control notification handler code here
	if(m_valid==true&&m_counting==false)
	{
	UpdateData(true);
	if(m_show!="0.")
	{
	CString temp="";
	if(m_z==true) 
	{ temp="-";
	m_z=false;
	temp+=m_show;
	m_show=temp;
	}
	else
	{
	m_z=true;
    temp=m_show.Right(m_show.GetLength()-1); 
	m_show=temp;
	}
	}
	UpdateData(false);
	}
else if(m_counting==true)
	{
	m_counting=false;
	m_show="0.";
	UpdateData(false);
	}
}

void CComputerDlg::OnButton13() 
{
	// TODO: Add your control notification handler code here
	double temp=0;
UpdateData(true);
m_count2=atof(m_show);
switch(m_ch)
{
case '+':
	{
		temp=m_count1+m_count2;
		break;
	}
case '-':
	{
		temp=m_count1-m_count2;
		break;
	}
case '*':
	{
		temp=m_count1*m_count2;
		break;
	}
case '/':
	{
		temp=m_count1/m_count2;
		break;
	}
case '^':
	{
		temp=pow(m_count1,m_count2);
		break;
	}
}
//m_show.Format("%lf",temp);
/*
char show[13];
_gcvt(temp,13,show);	//双精度转化为字符串
m_show=show;
*/

	CString str;
str.Format("%0.13f",temp);
m_show=str;

int j=m_show.GetLength();
for(int i=m_show.GetLength()-1;i>0;i--)
if(m_show.GetAt(i)=='0')
{
m_show=m_show.Left(i);
}
else break;

/*
int i=m_show.Find('.');
i=m_show.GetLength()-i-1;
CString right=m_show.Right(i);
int j=atoi(right);
if(j==0) m_show=m_show.Left(i)+".";
*/
//	m_ch=' ';
	m_counting=false;
	m_dot=false;
	m_z=true;
	m_finish=true;
UpdateData(false);
	
}

void CComputerDlg::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	if(m_valid==true)
	{
	double i=atof(m_show);
	double x=0;
	if(m_wdd==1)
	{
		m_wdd=2;
		if(i>0)
		{
        x=30+10*log10(i);
//		m_show.Format("%lf",x);
		
		char show[10];
_gcvt(x,10,show);	//双精度转化为字符串
m_show=show;
/*
			CString str;
str.Format("%0.5f",x);
m_show=str;
		*/
		}
		else if(i==0) {}
		else 
		{
			m_show="函数输入无效.";
			m_valid=false;
		}
	}
	else if(m_wdd==3&&i>0)
	{
		m_wdd=2;
	    x=i-107;
//		m_show.Format("%lf",x);
	
		char show[10];
_gcvt(x,10,show);	//双精度转化为字符串
m_show=show;
	/*
	CString str;
str.Format("%0.5f",x);
m_show=str;
		*/
	}
	m_radio1=1;
	UpdateData(false);
	}
}

void CComputerDlg::OnRadio3() 
{
	// TODO: Add your control notification handler code here
	if(m_valid==true)
	{
	double i=atof(m_show);
	double x=0;
	if(m_wdd==1)
	{
		m_wdd=3;
		if(i>0)
		{
        x=30+10*log10(i)+107;
//		m_show.Format("%lf",x);
		
		char show[10];
_gcvt(x,10,show);	//双精度转化为字符串
m_show=show;
/*			CString str;
str.Format("%0.5f",x);
m_show=str;*/
		}
		else if(i==0){}
		else
		{
			m_show="函数输入无效";
			m_valid=false;
		}
	}
	else if(m_wdd==2&&i>0)
	{
		m_wdd=3;
	    x=i+107;
	//	m_show.Format("%lf",x);
		
		char show[10];
_gcvt(x,10,show);	//双精度转化为字符串
m_show=show;
/*
			CString str;
str.Format("%0.5f",x);
m_show=str;*/
	}
	m_radio1=2;
	UpdateData(false);
	}
}

void CComputerDlg::OnButton14() 
{
	// TODO: Add your control notification handler code here
	m_valid=true;
	m_show="0.";
	m_dot=false;
	m_radio1=0;
	m_radio2=0;
    m_wdd=1;
	m_finish=false;
	UpdateData(false);
}

void CComputerDlg::OnButton15() 
{
	// TODO: Add your control notification handler code here
	if(MyTotalP!=NULL) MyTotalP->DestroyWindow();
	MyTotalP=new CMyTotalP();
	MyTotalP->Create(IDD_DIALOG1);
	

	CRect rect;
	m_totalw.GetWindowRect(&rect);
	int length=rect.right-rect.left;
	int height=rect.bottom-rect.top;
	rect.left+=length;
	rect.right+=length+460;
	rect.bottom+=180;
	
	MyTotalP->MoveWindow(rect,false);
	
	MyTotalP->ShowWindow(SW_SHOW);
}

void CComputerDlg::OnButton16() 
{
	// TODO: Add your control notification handler code here
	if(MyXLS!=NULL) MyXLS->DestroyWindow();
	MyXLS=new CMyXLS();
	MyXLS->Create(IDD_DIALOG2);
	

	CRect rect;
	m_xls.GetWindowRect(&rect);
	int length=rect.right-rect.left;
	int height=rect.bottom-rect.top;
	rect.left+=length;
	rect.right+=length+180;
	rect.bottom+=180;
	
	MyXLS->MoveWindow(rect,false);
	
	MyXLS->ShowWindow(SW_SHOW);
}

void CComputerDlg::OnButton17() 
{
	// TODO: Add your control notification handler code here
   if(MybjC!=NULL) MybjC->DestroyWindow();
	MybjC=new CMybjC();
	MybjC->Create(IDD_DIALOG3);
	
	CRect rect;
	m_bjC.GetWindowRect(&rect);
	int length=rect.right-rect.left;
	int height=rect.bottom-rect.top;
	rect.left+=length;
	rect.right+=length+360;
	rect.bottom+=240;
	
	MybjC->MoveWindow(rect,false);
	
	MybjC->ShowWindow(SW_SHOW);
}



void CComputerDlg::OnButton18() 
{
	// TODO: Add your control notification handler code here
	  if(MyLength!=NULL) MyLength->DestroyWindow();
	MyLength=new CMyLength();
	MyLength->Create(IDD_DIALOG4);
	
	CRect rect;
	m_MyLength.GetWindowRect(&rect);
	int length=rect.right-rect.left;
	int height=rect.bottom-rect.top;
	rect.left+=length;
	rect.right+=length+180;
	rect.bottom+=240;
	
	MyLength->MoveWindow(rect,false);
	
	MyLength->ShowWindow(SW_SHOW);
}

void CComputerDlg::OnRadio4() 
{
	// TODO: Add your control notification handler code here
	m_radio2=0;
	m_F=1000;
}

void CComputerDlg::OnRadio5() 
{
	// TODO: Add your control notification handler code here
		m_radio2=1;
	m_F=880;
}

void CComputerDlg::OnRadio6() 
{
	// TODO: Add your control notification handler code here
		m_radio2=2;
	m_F=1870;
}

void CComputerDlg::OnRadio7() 
{
	// TODO: Add your control notification handler code here
		m_radio2=3;
	m_F=2000;
}

void CComputerDlg::OnButton22() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_count1=atof(m_show);
	m_ch='+';
	m_counting=true;
	m_dot=false;
	m_z=true;
	UpdateData(false);
  
}

void CComputerDlg::OnButton21() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_count1=atof(m_show);
	m_ch='-';
	m_counting=true;
	m_dot=false;
	m_z=true;
	UpdateData(false);	
}

void CComputerDlg::OnButton20() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_count1=atof(m_show);
	m_ch='*';
	m_counting=true;
	m_dot=false;
	m_z=true;
	UpdateData(false);
}

void CComputerDlg::OnButton19() 
{
	// TODO: Add your control notification handler code here
		UpdateData(true);
	m_count1=atof(m_show);
	m_ch='/';
	m_counting=true;
	m_dot=false;
	m_z=true;
	UpdateData(false);
}

void CComputerDlg::OnButton23() 
{
	// TODO: Add your control notification handler code here
		UpdateData(true);
	m_count1=atof(m_show);
	double temp=log10(m_count1);
//	m_show.Format("%lf",temp);
/*
char show[10];
_gcvt(temp,10,show);	//双精度转化为字符串
m_show=show;
*/
		CString str;
str.Format("%0.5f",temp);
m_show=str;
	UpdateData(false);
}

void CComputerDlg::OnButton24() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_count1=atof(m_show);
	double temp=log(m_count1);
//	m_show.Format("%lf",temp);
	/*
char show[10];
_gcvt(temp,10,show);	//双精度转化为字符串
m_show=show;
*/
		CString str;
str.Format("%0.5f",temp);
m_show=str;
UpdateData(false);
}


BOOL CComputerDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message==WM_KEYUP)
	{
		int i=pMsg->wParam;
		if(i==16) m_shift=false; 
	}
	if(pMsg->message==WM_KEYDOWN)
	{
    int i=pMsg->wParam;
	if(i==8) OnButton26();
	if(i==106) OnButton20();
	if(i==111||i==191) OnButton19();
	if(i==109||i==189) OnButton21();
	if(i==107) OnButton22();
	if(i==13) 
	{
		OnButton13();
		GetDlgItem(IDC_EDIT10)->SetFocus();
	}
	if(i==110||i==190) OnButton12();

	if(i==16) m_shift=true; 
	
	if((i>=48&&i<=57||i>=96&&i<=105)&&m_shift==false)
	{
		if(i>=96&&i<=105)
			i=i-48;
		CString num=i;
if(m_valid==true&&m_counting==false)
	{
	UpdateData(true);
	if(m_dot==false)
	{
	if(m_show=="0."||m_finish==true)
	m_show=num+".";
	else
	{
	m_show=m_show.Left(m_show.GetLength()-1)+num+".";
	}
	}
	else m_show+=num;
	UpdateData(false);
	}
else if(m_counting==true)
	{
	m_counting=false;
	UpdateData(true);
	if(m_dot==false)
	m_show=num+".";
	else m_show+=num;
	UpdateData(false);
	}
if(m_finish==true) m_finish=false;
	}
if(m_shift==true&&i==56)
	{
		m_shift=false;
        OnButton20();
	}
if(m_shift==true&&i==56)
	{
		m_shift=false;
        OnButton20();
	}
if(m_shift==true&&i==187)
	{
		m_shift=false;
        OnButton22();
	}
	}
	return CDialog::PreTranslateMessage(pMsg);
}

void CComputerDlg::OnP() 
{
	// TODO: Add your command handler code here
	OnButton15(); 
}

void CComputerDlg::Onsh() 
{
	// TODO: Add your command handler code here
	OnButton16(); 
}

void CComputerDlg::Oncq() 
{
	// TODO: Add your command handler code here
OnButton17(); 
}

void CComputerDlg::Onlength() 
{
	// TODO: Add your command handler code here
	OnButton18(); 
}

void CComputerDlg::OnButton25() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_count1=atof(m_show);
	m_ch='^';
	m_counting=true;
	m_dot=false;
	m_z=true;
	UpdateData(false);
}

void CComputerDlg::OnButton26() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	if(m_show!="0.")
	{
		if(m_show.Right(1)==".")
		m_show=m_show.Left(m_show.GetLength()-2);
		else
       m_show=m_show.Left(m_show.GetLength()-1);
	}

	if(m_show.Find(".")==-1)
		m_show+=".";
	if(m_show==".")
	{
		m_show="0.";
		m_dot=false;
	}
	UpdateData(false);
}



void CComputerDlg::OnOK() 
{
	// TODO: Add extra validation here
	
//	CDialog::OnOK();
}

void CComputerDlg::Onexit() 
{
	// TODO: Add your command handler code here
	CDialog::OnCancel();
}

void CComputerDlg::Onabout() 
{
	// TODO: Add your command handler code here
	CAboutDlg a;
	a.DoModal();
}

void CComputerDlg::OnHelp() 
{
	// TODO: Add your command handler code here
	if(MyExplain!=NULL) MyExplain->DestroyWindow();
	MyExplain=new CMyExplain();
	MyExplain->Create(IDD_DIALOG5);
	
	MyExplain->ShowWindow(SW_SHOW);
}

void CComputerDlg::OnButton27() 
{
	// TODO: Add your control notification handler code here
	if(MyConvert!=NULL) MyConvert->DestroyWindow();
	MyConvert=new CMyConvert();
	MyConvert->Create(IDD_DIALOG_Convert);
	
	CRect rect;
	m_convert.GetWindowRect(&rect);
	int length=rect.right-rect.left;
	int height=rect.bottom-rect.top;
	rect.left+=length;
	rect.right+=length+245;
	rect.bottom+=280;
	
	MyConvert->MoveWindow(rect,false);
	
	MyConvert->ShowWindow(SW_SHOW);
}

void CComputerDlg::OnconvertF() 
{
	// TODO: Add your command handler code here
	OnButton27();
}

⌨️ 快捷键说明

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