📄 calculatordlg.h
字号:
// CalculatorDlg.h : header file
//
#if !defined(AFX_CALCULATORDLG_H__5617F3C6_55CB_4E76_9644_16CC7D5AD622__INCLUDED_)
#define AFX_CALCULATORDLG_H__5617F3C6_55CB_4E76_9644_16CC7D5AD622__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CCalculatorDlg dialog
#include "NewButton.h"
#include "NewEdit.h"
class CCalculatorDlg : public CDialog
{
// Construction
public:
void Dec2Bin(CString *strExp);
void Dec2Oct(CString *strExp);
CString MainPro(CString strExp); //主处理函数
void Dec2Hex(CString *strExp);
CCalculatorDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCalculatorDlg)
enum { IDD = IDD_CALCULATOR_DIALOG };
CButton m_standard;
CNewButton m_ok;
CNewEdit m_output;
CNewButton m_extend;
CNewButton m_xo;
CNewButton m_xh;
CNewButton m_xb;
CNewButton m_th;
CNewButton m_tan1;
CNewButton m_tan;
CNewButton m_sqrt;
CNewButton m_sqr;
CNewButton m_space;
CNewButton m_sin1;
CNewButton m_sin;
CNewButton m_sh;
CNewButton m_rparen;
CNewButton m_plus;
CNewButton m_operator;
CNewButton m_mul;
CNewButton m_mod;
CNewButton m_minus;
CNewButton m_lparen;
CNewButton m_log;
CNewButton m_ln;
CNewButton m_history;
CNewButton m_hf;
CNewButton m_exp;
CNewButton m_esqr;
CNewButton m_he;
CNewButton m_dot;
CNewButton m_divid;
CNewButton m_hd;
CNewButton m_cot;
CNewButton m_cos1;
CNewButton m_cos;
CNewButton m_const;
CNewButton m_clear;
CNewButton m_ch;
CNewButton m_hc;
CNewButton m_back;
CNewButton m_hb;
CNewButton m_abs;
CNewButton m_ha;
CNewButton m_nine;
CNewButton m_eight;
CNewButton m_seven;
CNewButton m_six;
CNewButton m_five;
CNewButton m_four;
CNewButton m_three;
CNewButton m_one;
CNewButton m_two;
CButton m_radDec;
CButton m_degree;
CNewEdit m_strExpc;
CNewButton m_zero;
CString m_strExp;
CString m_strRes;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCalculatorDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
afx_msg void OnMenuSelect(UINT nID);
CMenu m_menu;
CStringArray m_menuItem;
CMenu m_menu2;
int m_nEnd;
int m_nStart;
int m_nlen;
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CCalculatorDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButtonOperate();
afx_msg void OnButtonClear();
afx_msg void OnButtonConst();
afx_msg void OnRadioDec();
afx_msg void OnRadioHex();
afx_msg void OnRadioOct();
afx_msg void OnRadioBin();
afx_msg void OnButton7();
afx_msg void OnButton0();
afx_msg void OnButton1();
afx_msg void OnButton2();
afx_msg void OnButton3();
afx_msg void OnButton4();
afx_msg void OnButton5();
afx_msg void OnButton6();
afx_msg void OnButton8();
afx_msg void OnButton9();
afx_msg void OnButtonA();
afx_msg void OnButtonAbs();
afx_msg void OnButtonB();
afx_msg void OnButtonBack();
afx_msg void OnButtonC();
afx_msg void OnButtonCh();
afx_msg void OnButtonCos();
afx_msg void OnButtonCos1();
afx_msg void OnButtonCot();
afx_msg void OnButtonD();
afx_msg void OnButtonDivid();
afx_msg void OnButtonDot();
afx_msg void OnButtonE();
afx_msg void OnButtonEsqr();
afx_msg void OnButtonExp();
afx_msg void OnButtonF();
afx_msg void OnButtonLn();
afx_msg void OnButtonLog();
afx_msg void OnButtonLparen();
afx_msg void OnButtonMinus();
afx_msg void OnButtonMod();
afx_msg void OnButtonMul();
afx_msg void OnButtonPlus();
afx_msg void OnButtonRparen();
afx_msg void OnButtonSh();
afx_msg void OnButtonSin();
afx_msg void OnButtonSin1();
afx_msg void OnButtonSpace();
afx_msg void OnButtonSqr();
afx_msg void OnButtonSqrt();
afx_msg void OnButtonTan();
afx_msg void OnButtonTan1();
afx_msg void OnButtonTh();
afx_msg void OnButtonXb();
afx_msg void OnButtonXh();
afx_msg void OnButtonXo();
afx_msg void OnButtonHistory();
afx_msg void OnMenuC();
afx_msg void OnMenuE();
afx_msg void OnMenuE0();
afx_msg void OnMenuG();
afx_msg void OnMenuK();
afx_msg void OnMenuKe();
afx_msg void OnMenuNa();
afx_msg void OnMenuPi();
afx_msg void OnMenuR();
afx_msg void OnMenuVm();
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnRadioStandard();
afx_msg void OnRadioScientfic();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
int m_strLength;
CString m_strTmp;
CString m_strResTmp;
CRect largeCrect; //存放科学型界面的大小
CRect smallCrect; //存放标准型界面的大小
CRect separater; //科学型与标准型之间的分界线位置
CBitmap m_BKbitmap;
char opt2[6];
CString opt[15];
CString m_strConName[15];
CString m_strConValue[15];
bool m_bDegree;
void AddToHistr(CString strExp);
void Paster(CString strSign,BOOL bIsSingle);
void Calcu(CString *strExp,int pos); //*二元运算的预处理函数*
void Macro(CString *strExp); //*常数宏代换*
void Oct2Dec(CString *strExp); //*处理8进制数*
void Bin2Dec(CString *strExp); //*处理2进制数*
void Hex2Dec(CString *strExp); //*处理16进制数*
void MultiE(CString *strExp); //*多元运算*
void MinusMinus(CString *strExp); //*处理负负得正*
void DelBracket(CString *strExp); //*用计算结果替换表达式*
bool SynRes(CString *strExp); //*判断表达式是否合法*
CString ModiResult(CString strRes); //*在格式上处理最后的计算结果*
CString NtoS(double d); //*数字转字串*
CString SingleE(CString op,double dx); //*一元运算*
CString TwoE(CString strExp); //*二元运算*
bool IsDigital(CString str); //*判断表达式中是否有函数或运算符*
int BraCheck(CString str); //*计算左右括号的差值*
int LocateLBra(CString strExp); //*定位最后一个左括号*
double StoN(CString str);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CALCULATORDLG_H__5617F3C6_55CB_4E76_9644_16CC7D5AD622__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -