VC++6.0自编程序

源代码在线查看: cout.cpp

软件大小: 303 K
上传用户: changke8311
关键词: 6.0 VC 自编程
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Cout.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "WoDeZuoYe.h"
				#include "Cout.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				/////////////////////////////////////////////////////////////////////////////
				// CCout dialog
				
				
				CCout::CCout(CWnd* pParent /*=NULL*/)
					: CDialog(CCout::IDD, pParent)
				{
					//{{AFX_DATA_INIT(CCout)
					m_edit = _T("");
					//}}AFX_DATA_INIT
					m_edit="0" ;
					 m_n=0;
				     m_second_num=0;
					 m_first_num=0;
					 m_flag=1;
					 point=0 ;
				}
				
				
				void CCout::DoDataExchange(CDataExchange* pDX)
				{
					CDialog::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CCout)
					DDX_Text(pDX, IDC_EDIT1, m_edit);
					//}}AFX_DATA_MAP
				}
				
				
				BEGIN_MESSAGE_MAP(CCout, CDialog)
					//{{AFX_MSG_MAP(CCout)
					ON_BN_CLICKED(IDC_BUT1, OnBut1)
					ON_BN_CLICKED(IDC_BUT2, OnBut2)
					ON_BN_CLICKED(IDC_BUT3, OnBut3)
					ON_BN_CLICKED(IDC_BUT4, OnBut4)
					ON_BN_CLICKED(IDC_BUT5, OnBut5)
					ON_BN_CLICKED(IDC_BUT6, OnBut6)
					ON_BN_CLICKED(IDC_BUT7, OnBut7)
					ON_BN_CLICKED(IDC_BUT8, OnBut8)
					ON_BN_CLICKED(IDC_BUT9, OnBut9)
					ON_BN_CLICKED(IDC_BUT10, OnBut10)
					ON_BN_CLICKED(IDC_BUTJia, OnBUTJia)
					ON_BN_CLICKED(IDC_BUTJian, OnBUTJian)
					ON_BN_CLICKED(IDC_BUTCheng, OnBUTCheng)
					ON_BN_CLICKED(IDC_BUTChu, OnBUTChu)
					ON_BN_CLICKED(IDC_BUTDengYu, OnBUTDengYu)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CCout message handlers
				
				void CCout::OnBut1() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"1";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut2() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"2";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut3() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"3";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut4() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"4";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut5() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"5";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut6() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"6";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut7() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"7";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut8() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"8";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut9() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"9";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBut10() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					if(m_flag==1)
					{  m_edit="";
				     m_flag=0;
					}
					m_edit=	m_edit+"0";
				    m_num=atof(m_edit);
				  UpdateData(FALSE);
				}
				
				void CCout::OnBUTJia() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
						if(m_n==0) { m_first_num=atoi(m_edit) ; m_n=1; }
						else
						{
				
				
				
				         	m_second_num=m_num;
				        	switch( m_operator)
							{   case '+' :    m_first_num=m_first_num+m_second_num;break ;
					            case '-' :    m_first_num=m_first_num-m_second_num;break ;
					         	case '*' :    m_first_num=m_first_num*m_second_num;break ;
					            case '/' :    m_first_num=m_first_num/m_second_num;break ;
					         	default  :    MessageBox("Error") ; break ;
							}
						}
				     m_flag=1;
					 point=0;   
				   m_operator='+' ;
				   m_edit.Format("%f",m_first_num);
				   UpdateData(FALSE);
				}
				
				void CCout::OnBUTJian() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
						if(m_n==0) { m_first_num=atoi(m_edit) ; m_n=1; }
						else
						{
				
				
				
				         	m_second_num=m_num;
				        	switch( m_operator)
							{   case '+' :    m_first_num=m_first_num+m_second_num;break ;
					            case '-' :    m_first_num=m_first_num-m_second_num;break ;
					         	case '*' :    m_first_num=m_first_num*m_second_num;break ;
					            case '/' :    m_first_num=m_first_num/m_second_num;break ;
					         	default  :    MessageBox("Error") ; break ;
							}
						}
				     m_flag=1;
					 point=0;   
				   m_operator='-' ;
				   m_edit.Format("%f",m_first_num);
				   UpdateData(FALSE);
				}
				
				void CCout::OnBUTCheng() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
						if(m_n==0) { m_first_num=atoi(m_edit) ; m_n=1; }
						else
						{
				
				
				
				         	m_second_num=m_num;
				        	switch( m_operator)
							{   case '+' :    m_first_num=m_first_num+m_second_num;break ;
					            case '-' :    m_first_num=m_first_num-m_second_num;break ;
					         	case '*' :    m_first_num=m_first_num*m_second_num;break ;
					            case '/' :    m_first_num=m_first_num/m_second_num;break ;
					         	default  :    MessageBox("Error") ; break ;
							}
						}
				     m_flag=1;
					 point=0;   
				   m_operator='*' ;
				   m_edit.Format("%f",m_first_num);
				   UpdateData(FALSE);
				}
				
				void CCout::OnBUTChu() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
						if(m_n==0) { m_first_num=atoi(m_edit) ; m_n=1; }
						else
						{
				
				
				
				         	m_second_num=m_num;
				        	switch( m_operator)
							{   case '+' :    m_first_num=m_first_num+m_second_num;break ;
					            case '-' :    m_first_num=m_first_num-m_second_num;break ;
					         	case '*' :    m_first_num=m_first_num*m_second_num;break ;
					            case '/' :    m_first_num=m_first_num/m_second_num;break ;
					         	default  :    MessageBox("Error") ; break ;
							}
						}
				     m_flag=1;
					 point=0;   
				   m_operator='/' ;
				   m_edit.Format("%f",m_first_num);
				   UpdateData(FALSE);
				}
				
				void CCout::OnBUTDengYu() 
				{
					// TODO: Add your control notification handler code here
					UpdateData();
				
					m_second_num=m_num;
				
				
					switch( m_operator)
					{   case '+' :   m_edit.Format("%f",m_first_num+m_second_num);break ;
					    case '-' :   m_edit.Format("%f",m_first_num-m_second_num);break ;
						case '*' :   m_edit.Format("%f",m_first_num*m_second_num);break ;
					    case '/' :   m_edit.Format("%f",m_first_num/m_second_num);break ;
						default  :   MessageBox("Error") ; break ;
					}
				   m_flag=1;
				   point=0;
				   m_n=0  ;
				   m_first_num=atof( m_edit) ;
				   UpdateData(FALSE);
				}
							

相关资源