📄 calculator123dlg.cpp
字号:
// calculator123Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "calculator123.h"
#include "calculator123Dlg.h"
#include "constant.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCalculator123Dlg dialog
CCalculator123Dlg::CCalculator123Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CCalculator123Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCalculator123Dlg)
m_store = _T("");
m_str = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCalculator123Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCalculator123Dlg)
DDX_Control(pDX, IDC_moct, m_moct);
DDX_Control(pDX, IDC_mdec, m_mdec);
DDX_Control(pDX, IDC_mbin, m_mbin);
DDX_Control(pDX, IDC_mhex, m_mhex);
DDX_Control(pDX, IDC_cos, m_cos);
DDX_Control(pDX, IDCANCEL, m_cancle);
DDX_Control(pDX, IDC_zuo, m_zuo);
DDX_Control(pDX, IDC_you, m_you);
DDX_Control(pDX, IDC_th, m_th);
DDX_Control(pDX, IDC_tan, m_tan);
DDX_Control(pDX, IDC_sub, m_sub);
DDX_Control(pDX, IDC_sqr, m_sqr);
DDX_Control(pDX, IDC_sin, m_sin);
DDX_Control(pDX, IDC_sh, m_sh);
DDX_Control(pDX, IDC_point, m_point);
DDX_Control(pDX, IDC_pi, m_pi);
DDX_Control(pDX, IDC_OK, m_ok);
DDX_Control(pDX, IDC_mul, m_mul);
DDX_Control(pDX, IDC_mod, m_mod);
DDX_Control(pDX, IDC_log, m_log);
DDX_Control(pDX, IDC_ln, m_ln);
DDX_Control(pDX, IDC_exp, m_exp);
DDX_Control(pDX, IDC_ex, m_ex);
DDX_Control(pDX, IDC_eee, m_eee);
DDX_Control(pDX, IDC_e, m_e);
DDX_Control(pDX, IDC_div, m_div);
DDX_Control(pDX, IDC_cot, m_cot);
DDX_Control(pDX, IDC_con, m_con);
DDX_Control(pDX, IDC_clear, m_clear);
DDX_Control(pDX, IDC_ch, m_ch);
DDX_Control(pDX, IDC_BTN_OCT, m_oct);
DDX_Control(pDX, IDC_BTN_HEX, m_hex);
DDX_Control(pDX, IDC_BTN_BIN, m_bin);
DDX_Control(pDX, IDC_back, m_back);
DDX_Control(pDX, IDC_Arctan, m_arctan);
DDX_Control(pDX, IDC_Arcsin, m_arcsin);
DDX_Control(pDX, IDC_Arccos, m_arccos);
DDX_Control(pDX, IDC_add, m_add);
DDX_Control(pDX, IDC_abs, m_abs);
DDX_Control(pDX, IDC_9, m_9);
DDX_Control(pDX, IDC_8, m_8);
DDX_Control(pDX, IDC_7, m_7);
DDX_Control(pDX, IDC_6, m_6);
DDX_Control(pDX, IDC_5, m_5);
DDX_Control(pDX, IDC_4, m_4);
DDX_Control(pDX, IDC_3, m_3);
DDX_Control(pDX, IDC_2, m_2);
DDX_Control(pDX, IDC_15, m_15);
DDX_Control(pDX, IDC_14, m_14);
DDX_Control(pDX, IDC_13, m_13);
DDX_Control(pDX, IDC_12, m_12);
DDX_Control(pDX, IDC_11, m_11);
DDX_Control(pDX, IDC_10, m_10);
DDX_Control(pDX, IDC_1, m_1);
DDX_Control(pDX, IDC_0, m_0);
DDX_Control(pDX, IDC_HISTORY, m_ListBox); //放进历史中
DDX_Control(pDX, IDC_input, m_pointstore);
DDX_Control(pDX, IDC_RADIO_RADIAN, m_radio_radian);
DDX_Control(pDX, IDC_RADIO_DEGREE, m_radio_degree);
DDX_Text(pDX, IDC_input, m_store);
DDX_Text(pDX, IDC_output, m_strRes);
DDX_LBString(pDX, IDC_HISTORY, m_str); //从历史中找表达式
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCalculator123Dlg, CDialog)
//{{AFX_MSG_MAP(CCalculator123Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_7, On7)
ON_BN_CLICKED(IDC_8, On8)
ON_BN_CLICKED(IDC_9, On9)
ON_BN_CLICKED(IDC_4, On4)
ON_BN_CLICKED(IDC_5, On5)
ON_BN_CLICKED(IDC_6, On6)
ON_BN_CLICKED(IDC_1, On1)
ON_BN_CLICKED(IDC_2, On2)
ON_BN_CLICKED(IDC_3, On3)
ON_BN_CLICKED(IDC_0, On0)
ON_BN_CLICKED(IDC_point, Onpoint)
ON_BN_CLICKED(IDC_add, Onadd)
ON_BN_CLICKED(IDC_sub, Onsub)
ON_BN_CLICKED(IDC_mul, Onmul)
ON_BN_CLICKED(IDC_zuo, Onzuo)
ON_BN_CLICKED(IDC_div, Ondiv)
ON_BN_CLICKED(IDC_ex, Onex)
ON_BN_CLICKED(IDC_mod, Onmod)
ON_BN_CLICKED(IDC_you, Onyou)
ON_BN_CLICKED(IDC_10, On10)
ON_BN_CLICKED(IDC_11, On11)
ON_BN_CLICKED(IDC_12, On12)
ON_BN_CLICKED(IDC_13, On13)
ON_BN_CLICKED(IDC_14, On14)
ON_BN_CLICKED(IDC_15, On15)
ON_BN_CLICKED(IDC_pi, Onpi)
ON_BN_CLICKED(IDC_e, One)
ON_BN_CLICKED(IDC_back, Onback)
ON_BN_CLICKED(IDC_clear, Onclear)
ON_BN_CLICKED(IDC_con, Oncon)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_sin, Onsin)
ON_BN_CLICKED(IDC_cos, Oncos)
ON_BN_CLICKED(IDC_tan, Ontan)
ON_BN_CLICKED(IDC_cot, Oncot)
ON_BN_CLICKED(IDC_Arcsin, OnAsin)
ON_BN_CLICKED(IDC_Arccos, OnAcos)
ON_BN_CLICKED(IDC_Arctan, OnAtan)
ON_BN_CLICKED(IDC_log, Onlog)
ON_BN_CLICKED(IDC_sh, Onsh)
ON_BN_CLICKED(IDC_ch, Onch)
ON_BN_CLICKED(IDC_th, Onth)
ON_BN_CLICKED(IDC_ln, Onln)
ON_BN_CLICKED(IDC_eee, Oneee)
ON_BN_CLICKED(IDC_sqr, Onsqr)
ON_BN_CLICKED(IDC_abs, Onabs)
ON_BN_CLICKED(IDC_exp, Onexp)
ON_BN_CLICKED(IDC_OK, OnOk)
ON_BN_CLICKED(IDC_BTN_BIN, OnBtnBin)
ON_BN_CLICKED(IDC_BTN_OCT, OnBtnOct)
ON_BN_CLICKED(IDC_BTN_HEX, OnBtnHex)
ON_LBN_SELCHANGE(IDC_HISTORY, OnSelchangeHistory)
ON_BN_CLICKED(IDC_mhex, Onmhex)
ON_BN_CLICKED(IDC_mdec, Onmdec)
ON_BN_CLICKED(IDC_moct, Onmoct)
ON_BN_CLICKED(IDC_mbin, Onmbin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCalculator123Dlg message handlers
BOOL CCalculator123Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
open=new Cconstant; //定义指针
open->Create(IDD_constant); //弹出对话框
broad=0;
m_radio_radian.SetCheck(1); //默认制度为弧度
m_mdec.SetCheck(1); //默认进制为10进制
m_10.EnableWindow(FALSE); //默认进制为10进制,应屏蔽掉a~f键
m_11.EnableWindow(FALSE);
m_12.EnableWindow(FALSE);
m_13.EnableWindow(FALSE);
m_14.EnableWindow(FALSE);
m_15.EnableWindow(FALSE);
m_bin.EnableWindow(FALSE); //2进制标识符相应屏蔽掉
m_oct.EnableWindow(FALSE); //8进制标识符相应屏蔽掉
m_hex.EnableWindow(FALSE); //16进制标识符相应屏蔽掉
return TRUE; // return TRUE unless you set the focus to a control
}
void CCalculator123Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCalculator123Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCalculator123Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCalculator123Dlg::yingshe(CString strSign, BOOL bIsSingle)
{
UpdateData(1);
CString str;
m_nlength=m_store.GetLength();
m_pointstore.GetSel(m_nstart,m_nend);
str=m_store.Mid(m_nend,m_nlength-m_nend);
m_store=m_store.Left(m_nstart)+strSign;
m_nlength=m_store.GetLength();
if(bIsSingle) m_nlength-=1;
m_store+=str;
UpdateData(0);
m_pointstore.SetFocus();
m_pointstore.SetSel(m_nlength,m_nlength);
}
void CCalculator123Dlg::On7()
{
// TODO: Add your control notification handler code here
yingshe("7",0);
}
void CCalculator123Dlg::On8()
{
// TODO: Add your control notification handler code here
yingshe("8",0);
}
void CCalculator123Dlg::On9()
{
// TODO: Add your control notification handler code here
yingshe("9",0);
}
void CCalculator123Dlg::On4()
{
// TODO: Add your control notification handler code here
yingshe("4",0);
}
void CCalculator123Dlg::On5()
{
// TODO: Add your control notification handler code here
yingshe("5",0);
}
void CCalculator123Dlg::On6()
{
// TODO: Add your control notification handler code here
yingshe("6",0);
}
void CCalculator123Dlg::On1()
{
// TODO: Add your control notification handler code here
yingshe("1",0);
}
void CCalculator123Dlg::On2()
{
// TODO: Add your control notification handler code here
yingshe("2",0);
}
void CCalculator123Dlg::On3()
{
// TODO: Add your control notification handler code here
yingshe("3",0);
}
void CCalculator123Dlg::On0()
{
// TODO: Add your control notification handler code here
yingshe("0",0);
}
void CCalculator123Dlg::Onpoint()
{
// TODO: Add your control notification handler code here
yingshe(".",0);
}
void CCalculator123Dlg::Onadd()
{
// TODO: Add your control notification handler code here
yingshe("+",0);
}
void CCalculator123Dlg::Onsub()
{
// TODO: Add your control notification handler code here
yingshe("-",0);
}
void CCalculator123Dlg::Onmul()
{
// TODO: Add your control notification handler code here
yingshe("*",0);
}
void CCalculator123Dlg::Onzuo()
{
// TODO: Add your control notification handler code here
yingshe("(",0);
}
void CCalculator123Dlg::Ondiv()
{
// TODO: Add your control notification handler code here
yingshe("/",0);
}
void CCalculator123Dlg::Onex()
{
// TODO: Add your control notification handler code here
yingshe("^",0);
}
void CCalculator123Dlg::Onmod()
{
// TODO: Add your control notification handler code here
yingshe("%",0);
}
void CCalculator123Dlg::Onyou()
{
// TODO: Add your control notification handler code here
yingshe(")",0);
}
void CCalculator123Dlg::On10()
{
// TODO: Add your control notification handler code here
yingshe("a",0);
}
void CCalculator123Dlg::On11()
{
// TODO: Add your control notification handler code here
yingshe("b",0);
}
void CCalculator123Dlg::On12()
{
// TODO: Add your control notification handler code here
yingshe("c",0);
}
void CCalculator123Dlg::On13()
{
// TODO: Add your control notification handler code here
yingshe("d",0);
}
void CCalculator123Dlg::On14()
{
// TODO: Add your control notification handler code here
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -