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

📄 cfunc.cpp

📁 用C++实现的计算器的源程序
💻 CPP
字号:
// CFUNC.cpp : implementation file
//

#include "stdafx.h"
#include "Calculator.h"
#include "CFUNC.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCFUNC dialog


CCFUNC::CCFUNC(CWnd* pParent /*=NULL*/)
	: CDialog(CCFUNC::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCFUNC)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CCFUNC::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCFUNC)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCFUNC, CDialog)
	//{{AFX_MSG_MAP(CCFUNC)
	ON_WM_SETCURSOR()
	ON_BN_CLICKED(IDC_BNT_SIN, OnBntSin)
	ON_BN_CLICKED(IDC_BTN_COS, OnBtnCos)
	ON_BN_CLICKED(IDC_BNT_TAN, OnBntTan)
	ON_BN_CLICKED(IDC_BNT_COT, OnBntCot)
	ON_BN_CLICKED(IDC_BNT_LOG, OnBntLog)
	ON_BN_CLICKED(IDC_BNT_ARCCOS, OnBntArccos)
	ON_BN_CLICKED(IDC_BNT_ARCSIN, OnBntArcsin)
	ON_BN_CLICKED(IDC_BNT_LN, OnBntLn)
	ON_BN_CLICKED(IDC_BNT_SQR, OnBntSqr)
	ON_BN_CLICKED(IDC_BNT_ABS, OnBntAbs)
	ON_BN_CLICKED(IDC_BNT_SH, OnBntSh)
	ON_BN_CLICKED(IDC_BNT_EXP, OnBntExp)
	ON_BN_CLICKED(IDC_BNT_CH, OnBntCh)
	ON_BN_CLICKED(IDC_BNT_ARCTAN, OnBntArctan)
	ON_BN_CLICKED(IDC_BNT_TH, OnBntTh)
	ON_BN_CLICKED(IDC_BNT_10EXP, OnBnt10exp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCFUNC message handlers

BOOL CCFUNC::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_nCtrlID[0]=IDC_BNT_SIN;m_nCtrlID[1]=IDC_BTN_COS;m_nCtrlID[2]=IDC_BNT_TAN;
	m_nCtrlID[3]=IDC_BNT_COT;m_nCtrlID[4]=IDC_BNT_LOG;m_nCtrlID[5]=IDC_BNT_ARCCOS;
	m_nCtrlID[6]=IDC_BNT_ARCSIN;m_nCtrlID[7]=IDC_BNT_LN;m_nCtrlID[8]=IDC_BNT_SQR;
	m_nCtrlID[9]=IDC_BNT_ABS;m_nCtrlID[10]=IDC_BNT_SH;m_nCtrlID[11]=IDC_BNT_EXP;
	m_nCtrlID[12]=IDC_BNT_CH;m_nCtrlID[13]=IDC_BNT_ARCTAN;m_nCtrlID[14]=IDC_BNT_TH;
	m_nCtrlID[15]=IDC_BNT_10EXP;
	m_strCtrlName[0]="正弦";m_strCtrlName[1]="余弦";m_strCtrlName[2]="正切";
	m_strCtrlName[3]="余切";m_strCtrlName[4]="以10为底的对数";m_strCtrlName[5]="反余弦";
	m_strCtrlName[6]="反正弦";m_strCtrlName[7]="以e为底的对数";m_strCtrlName[8]="开平方";
	m_strCtrlName[9]="取绝对值";m_strCtrlName[10]="双曲正弦";m_strCtrlName[11]="e的幂次方";
	m_strCtrlName[12]="双曲余弦";m_strCtrlName[13]="反正切";m_strCtrlName[14]="双曲正切";
	m_strCtrlName[15]="10的幂次方";
	m_toolTip.Create( this );
	CStringArray straInfo;
	for(int i=0;i<16;i++)
	{
		straInfo.RemoveAll();
		straInfo.Add( m_strCtrlName[i] );
		m_toolTip.AddControlInfo( m_nCtrlID[i], straInfo, RGB(255,255,0) );
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CCFUNC::OnCancel() 
{
	m_strN="OVER";
	CDialog::OnCancel();
}

BOOL CCFUNC::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	UINT n=pWnd->GetDlgCtrlID();
	for(int i=0;i<16;i++)
	{
		if(n==m_nCtrlID[i]) 
		{
			m_toolTip.ShowToolTip( n );
			m_nCtrlIDTmp=n;
			return 1;
		}
	}
	m_toolTip.ErasePreviousToolTipDisplay(m_nCtrlIDTmp);

	return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

void CCFUNC::OnBntSin() 
{
	m_strN="sin( )";
}

void CCFUNC::OnBtnCos() 
{
	m_strN="cos( )";
}

void CCFUNC::OnBntTan() 
{
	m_strN="tan( )";
}

void CCFUNC::OnBntCot() 
{
	m_strN="cot( )";
}

void CCFUNC::OnBntLog() 
{
	m_strN="log( )";
}

void CCFUNC::OnBntArccos() 
{
	m_strN="ac( )";
}

void CCFUNC::OnBntArcsin() 
{
	m_strN="as( )";
}

void CCFUNC::OnBntLn() 
{
	m_strN="ln( )";
}

void CCFUNC::OnBntSqr() 
{
	m_strN="sqr( )";
}

void CCFUNC::OnBntAbs() 
{
	m_strN="abs( )";
}

void CCFUNC::OnBntSh() 
{
	m_strN="sh( )";
}

void CCFUNC::OnBntExp() 
{
	m_strN="e^( )";
}

void CCFUNC::OnBntCh() 
{
	m_strN="ch( )";
}

void CCFUNC::OnBntArctan() 
{
	m_strN="at( )";
}

void CCFUNC::OnBntTh() 
{
	m_strN="th( )";	
}

void CCFUNC::OnBnt10exp() 
{
	m_strN="exp( )";		
}

⌨️ 快捷键说明

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