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

📄 currency calculatordlg.h

📁 计算器 英国一个学生写的 代码很适合学习
💻 H
字号:
// Currency CalculatorDlg.h : header file
//

#if !defined(AFX_CURRENCYCALCULATORDLG_H__F9F50D6E_4441_4E02_9CC5_595FEC450983__INCLUDED_)
#define AFX_CURRENCYCALCULATORDLG_H__F9F50D6E_4441_4E02_9CC5_595FEC450983__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// Enumerated & Structure data definitions

enum operation					// operations of calculator
{
	none,
	addition,
	subtraction,
	multiplication,
	division
};

struct num_currency				// either holds double number or Currency
{	// Can't use union, as a union can't have a member with copy constructor
	// and Currency class has the same
	BOOL curr_flag;				// true for Currency and false for double
	Currency curr_num;			// Currency value
	double doub_num;			// double number value
	void make_null()			// make the structure null
	{
		curr_flag = false;
		curr_num.set_currency( 0 );
		doub_num = 0;
	}
	BOOL is_null()				// is this null
	{
		if( curr_flag==false
			&& (curr_num.get_notes()==0 && curr_num.get_coins()==0)
			&& doub_num==0 )
			return true;
		else
			return false;
	}
	void operator = (num_currency amount )	// overloaded equal operator
	{
		curr_flag = amount.curr_flag;
		curr_num.set_currency( amount.curr_num.get_currency() );
		doub_num = amount.doub_num;
	}
};

/////////////////////////////////////////////////////////////////////////////
// Constants

const WORD MAX_LENGTH = 10;		// maximum character length for result

/////////////////////////////////////////////////////////////////////////////
// CCurrencyCalculatorDlg dialog

class CCurrencyCalculatorDlg : public CDialog
{
// Construction
public:
	CCurrencyCalculatorDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CCurrencyCalculatorDlg)
	enum { IDD = IDD_CURRENCYCALCULATOR_DIALOG };
	CButton	m_radio1;
	CListBox	m_list1;
	int		m_curr_or_num;
	CString	m_amount;
	int		m_cur_sel;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCurrencyCalculatorDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CCurrencyCalculatorDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnAdd();
	afx_msg void OnCurrency();
	afx_msg void OnDivide();
	afx_msg void OnEqual();
	afx_msg void OnMultiply();
	afx_msg void OnNum0();
	afx_msg void OnNum1();
	afx_msg void OnNum2();
	afx_msg void OnNum3();
	afx_msg void OnNum4();
	afx_msg void OnNum5();
	afx_msg void OnNum6();
	afx_msg void OnNum7();
	afx_msg void OnNum8();
	afx_msg void OnNum9();
	afx_msg void OnNumber();
	afx_msg void OnPoint();
	afx_msg void OnSubtract();
	afx_msg void OnSelchangeList1();
	afx_msg void OnClear();
	afx_msg void OnClearall();
	afx_msg void OnBackspace();
	afx_msg void OnAbout();
	afx_msg void OnExit();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	num_currency first_num,		// first number of calculator operations
		intermediate_num,		// second operand (to be saved for successive equal ops.)
		result;					// result of operations
	operation last_op;			// last operation of calculator
	BOOL new_num_flag;			// flag for removing previous number on selecting operations
	CString remove_c_letter();	// removes currency letter from result string
	BOOL do_operation( num_currency );	// performs operation and return result
	void dbl_to_text( double, CString& );	// converts double value into text
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CURRENCYCALCULATORDLG_H__F9F50D6E_4441_4E02_9CC5_595FEC450983__INCLUDED_)

⌨️ 快捷键说明

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