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

📄 test1dlg.cpp

📁 本人设计的一个漂亮科学计算器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_SQRT);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_LN);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_LOG);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_MOD);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM8);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM9);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM7);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM6);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM5);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM4);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM3);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_NUM2);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_A);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_B);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_C);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_D);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_E);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CHAR_F);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_TAN);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_ATAN);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_EXP);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_INT);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_SQUARE);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_CUBE);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_INDEX);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_ABS);
	pWnd->EnableWindow(FALSE);

	pWnd = this->GetDlgItem(IDC_RECIPROCAL);
	pWnd->EnableWindow(FALSE);

	if(m_jucle==TRUE)
	{
		m_str4="";
		m_str4=m_str1;
		m_str1="";
		m_jucle=FALSE;  
	}

	if(m_ju2==TRUE)
	{
		if(10==m_nsel)
		{
			int i=0,j=0,aa=(int)atof(m_str4);
			int cc[30];
			char buffer[30];
			m_str4="";
			while(aa!=0)
			{
				cc[i]=aa%2;
				aa=aa/2;
				i++;
			}
			for(j=i-1;j>=0;j--)
			{
				m_str4+=itoa(cc[j],buffer,10);
			}
			SetDlgItemText(IDC_SHOW_RESULT,m_str4);
		}

		if(16==m_nsel)
		{
			double bb=0;
			for(int i=0;i<=m_str4.GetLength()-1;i++)
			{
				double pp=0;
				if(m_str4[i]>=65 && m_str4[i]<=70)
					pp=m_str4[i]-55.0;
				else
					pp=m_str4[i]-48.0;
				bb+=pp*pow(16.0,(double)(m_str4.GetLength()-i-1));
			}

			int k=0,j=0,aa=(int)bb;
			int cc[30];
			char buffer[30];
			m_str4="";
			while(aa!=0)
			{
				cc[k]=aa%2;
				aa=aa/2;
				k++;
			}
			for(j=k-1;j>=0;j--)
			{
				m_str4+=itoa(cc[j],buffer,10);
			}
			SetDlgItemText(IDC_SHOW_RESULT,m_str4);
		}

		if(8==m_nsel)
		{
			double bb=0;
			for(int i=0;i<=m_str4.GetLength()-1;i++)
			{
				bb+=(m_str4[i]-48.0)*pow(8.0,(double)(m_str4.GetLength()-i-1));
			}

			int k=0,j=0,aa=(int)bb;
			int cc[30];
			char buffer[30];
			m_str4="";
			while(aa!=0)
			{
				cc[k]=aa%2;
				aa=aa/2;
				k++;
			}
			for(j=k-1;j>=0;j--)
			{
				m_str4+=itoa(cc[j],buffer,10);
			}
			SetDlgItemText(IDC_SHOW_RESULT,m_str4);
		}

		m_nsel=2;
		m_ju16=TRUE; m_ju10=TRUE; m_ju8=TRUE; m_ju2=FALSE;
	}
}

void CTest1Dlg::OnCharA() 
{
	// TODO: Add your control notification handler code here
	m_str1+="A";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnCharB() 
{
	// TODO: Add your control notification handler code here
	m_str1+="B";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnCharC() 
{
	// TODO: Add your control notification handler code here
	m_str1+="C";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnCharD() 
{
	// TODO: Add your control notification handler code here
	m_str1+="D";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnCharE() 
{
	// TODO: Add your control notification handler code here
	m_str1+="E";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnCharF() 
{
	// TODO: Add your control notification handler code here
	m_str1+="F";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
	m_nsel=16;
	m_jucle=TRUE;
}

void CTest1Dlg::OnTan() 
{
	// TODO: Add your control notification handler code here
	CString InsertStr("");
	CString str;

	int aa=GetCheckedRadioButton(IDC_ANGLE,IDC_RADIAN);
	if(aa==1023)
	{
		m_show=tan(atof(m_str1)*3.141592653589793238/180);
	}
	if(aa==1024)
	{
		m_show=tan(atof(m_str1));
	}
	UpdateData(FALSE);

	str.Format("%lf",m_show);
	InsertStr += "tan(";
	InsertStr += m_str1;
	InsertStr += ")=";
	InsertStr += str;
	m_pList->m_list.InsertString(0,InsertStr);

	m_str1="";
}

void CTest1Dlg::OnAtan() 
{
	// TODO: Add your control notification handler code here
	CString InsertStr("");
	CString str;

	int aa=GetCheckedRadioButton(IDC_ANGLE,IDC_RADIAN);
	if(aa==1023)
	{
		m_show=atan(atof(m_str1));  
		m_show=m_show*180/3.141592653589793238;
	}
	if(aa==1024)
	{
		m_show=atan(atof(m_str1));	
	}
	UpdateData(FALSE);

	str.Format("%lf",m_show);
	InsertStr += "atan(";
	InsertStr += m_str1;
	InsertStr += ")=";
	InsertStr += str;
	m_pList->m_list.InsertString(0,InsertStr);

	m_str1=""; 
}

void CAboutDlg::OnEmail() 
{
	// TODO: Add your control notification handler code here
	char szMailAddress[80];
	strcpy(szMailAddress,"mailto:zaishuiyiren188@sina.com");
	ShellExecute(NULL,
				"open",
				szMailAddress,
				NULL,
				NULL,
				SW_SHOWNORMAL);
}

void CTest1Dlg::OnAboutButton() 
{
	// TODO: Add your control notification handler code here
	CAboutDlg dlg;
	dlg.DoModal(); 
}

HBRUSH CTest1Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	HBRUSH hbrush;
	switch(pWnd->GetDlgCtrlID())
	{
		case IDC_SHOW_RESULT: 
			pDC->SetTextColor(RGB(255,0,0));
			pDC->SetBkMode(TRANSPARENT);
			hbrush = CreateSolidBrush(RGB(100,150,255));
			hbr = hbrush;
			break; 
		default:
			break; 
	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}



BOOL CTest1Dlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(NULL != m_pToolTip)   
		m_pToolTip->RelayEvent(pMsg);
	return CDialog::PreTranslateMessage(pMsg);
}

BOOL CTest1Dlg::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	delete m_pToolTip;
	return CDialog::DestroyWindow();
}

void CTest1Dlg::OnTest() 
{
	// TODO: Add your control notification handler code here
	if(!bIsFuncBoardOpen)
	{
		GetWindowRect(m_rect);
//		m_pList->SetWindowPos(NULL,m_rect.left+485,m_rect.top,-1,-1,SWP_NOSIZE);
		m_pList->SetWindowPos(NULL,m_rect.right,m_rect.top,-1,-1,SWP_NOSIZE);
		m_pList->ShowWindow(SW_SHOW);
		SetTimer(2,200,NULL);
		bIsFuncBoardOpen=1;
	}
	else
	{
		m_pList->ShowWindow(SW_HIDE);
		bIsFuncBoardOpen=0;
		KillTimer(2);
	}
}



void CTest1Dlg::OnExtend() 
{
	// TODO: Add your control notification handler code here
	CString str;
	if(GetDlgItemText(IDC_EXTEND,str),str=="收缩<<")
	{
		SetDlgItemText(IDC_EXTEND,"扩展>>");
	}
	else
	{
		SetDlgItemText(IDC_EXTEND,"收缩<<");
	}

	static CRect rectLarge;
	static CRect rectSmall;

	CRect rectSeparator;
	GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator);
	if(str=="收缩<<")
	{
		SetWindowPos(NULL,0,0,m_rectSmall.Width(),m_rectSmall.Height(),
			SWP_NOMOVE | SWP_NOZORDER);
	}
	else
	{
		SetWindowPos(NULL,0,0,m_rectLarge.Width(),m_rectLarge.Height(),
			SWP_NOMOVE | SWP_NOZORDER);
	}
}

void CTest1Dlg::OnExp() 
{
	// TODO: Add your control notification handler code here
	if(m_str1!="")
	{
		m_str3="exp";
		m_str2=m_str1;
		m_str1+=".e+0";
		SetDlgItemText(IDC_SHOW_RESULT,m_str1);
		m_juexp=TRUE;
	}
}

void CTest1Dlg::OnInt() 
{
	// TODO: Add your control notification handler code here
	if(m_str1!="")
	{
		CString InsertStr("");
		InsertStr+="Int(";
		InsertStr+=m_str1;
		InsertStr+=")=";

		m_str1.Format("%d",(int)atof(m_str1));
		SetDlgItemText(IDC_SHOW_RESULT,m_str1);
		
		InsertStr+=m_str1;
		m_pList->m_list.InsertString(0,InsertStr);

		m_str1="";
	}
}

void CTest1Dlg::OnSquare() 
{
	// TODO: Add your control notification handler code here
	m_show=pow(atof(m_str1),2.0);
	UpdateData(FALSE);
	
	CString InsertStr("");
	CString str("");
	InsertStr+=m_str1;
	InsertStr+="^2";
	InsertStr+="=";
	str.Format("%lf",m_show);
	InsertStr+=str;
	m_pList->m_list.InsertString(0,InsertStr);

	m_str1="";
}

void CTest1Dlg::OnCube() 
{
	// TODO: Add your control notification handler code here
	m_show=pow(atof(m_str1),3.0);
	UpdateData(FALSE);

	CString InsertStr("");
	CString str("");
	InsertStr+=m_str1;
	InsertStr+="^3";
	InsertStr+="=";
	str.Format("%lf",m_show);
	InsertStr+=str;
	m_pList->m_list.InsertString(0,InsertStr);

	m_str1="";
}

void CTest1Dlg::OnIndex() 
{
	// TODO: Add your control notification handler code here
	m_str3="x^y";
	m_str2=m_str1;
	m_str1="";
}

void CTest1Dlg::OnReciprocal() 
{
	// TODO: Add your control notification handler code here
	m_show=pow(atof(m_str1),-1.0);
	UpdateData(FALSE);

	CString InsertStr("");
	CString str("");
	InsertStr+="1/";
	InsertStr+=m_str1;
	InsertStr+="=";
	str.Format("%lf",m_show);
	InsertStr+=str;
	m_pList->m_list.InsertString(0,InsertStr);

	m_str1="";
}

void CTest1Dlg::OnAbs() 
{
	// TODO: Add your control notification handler code here
	if(m_str1!="")
	{
		if(atof(m_str1)<0)
			m_show=-1*atof(m_str1);
		else
			m_show=atof(m_str1);
		UpdateData(FALSE);

		CString InsertStr("");
		CString str("");
		InsertStr+="abs(";
		InsertStr+=m_str1;
		InsertStr+=")=";
		str.Format("%lf",m_show);
		InsertStr+=str;
		m_pList->m_list.InsertString(0,InsertStr);

		m_str1="";
	}
}

void CTest1Dlg::OnConstantdata() 
{
	// TODO: Add your control notification handler code here
	UpdateData(1);
	CWnd * pFrame;					
	pFrame=AfxGetApp()->GetMainWnd();
	CWnd* pWndPopupOwner = this;
	VERIFY(m_menu.LoadMenu(IDR_MENU1));
	CPoint point;
	GetCursorPos(&point);
	::SetForegroundWindow(m_hWnd); 
	CMenu* pPopup = m_menu.GetSubMenu(0);
	CRect rect;
	GetDlgItem(IDC_CONSTANTDATA)->GetWindowRect(&rect);
	pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,rect.left,rect.top+rect.Height(),pWndPopupOwner,NULL);
	m_menu.DestroyMenu();
}

void CTest1Dlg::OnPi() 
{
	// TODO: Add your command handler code here
	m_str1="3.141592653589793";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
}

void CTest1Dlg::OnE() 
{
	// TODO: Add your command handler code here
	m_str1="2.718281828459045";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
}

void CTest1Dlg::OnVm() 
{
	// TODO: Add your command handler code here
	m_str1="0.02241383";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
}

void CTest1Dlg::OnEf() 
{
	// TODO: Add your command handler code here
	m_str1="8988000000.000000";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
}

void CTest1Dlg::OnMg() 
{
	// TODO: Add your command handler code here
	m_str1="8.3144";
	SetDlgItemText(IDC_SHOW_RESULT,m_str1);
}

⌨️ 快捷键说明

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