Click here to Skip to main content
15,881,867 members
Articles / Desktop Programming / ATL

Visual Calc v3.0 - A new dimension for the desktop calculator

Rate me:
Please Sign up or sign in to vote.
3.62/5 (113 votes)
28 Apr 2006CPOL22 min read 348.7K   6.8K   104  
How to start programming a parser.
/* VisualCalcDlg.h
 *
 * Copyright (c) 2004-2006 by toxcct. All rights reserved.
 * Consult your license regarding permissions and restrictions.
 */

// VisualCalcDlg.h : header file
//

#if !defined(__AFX_VISUALCALCDLG_H_INCLUDED__)
#define		 __AFX_VISUALCALCDLG_H_INCLUDED__

#if _MSC_VER > 1000
#pragma once
#endif

#include <CSTDIO>			// std::sprintf
#include "AboutDlg.h"
#include "HelpSheetDlg.h"
#include "VCalcParser.h"	// The parser, its types, its exceptions


// CVisualCalcDlg dialog
class CVisualCalcDlg : public CDialog {
public:
	CVisualCalcDlg(CWnd* pParent = NULL);

	//{{AFX_DATA(CVisualCalcDlg)
	enum { IDD = IDD_VISUALCALC_DIALOG };
	//}}AFX_DATA

	//{{AFX_VIRTUAL(CVisualCalcDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

protected:
	HICON m_hIcon;

	//{{AFX_MSG(CVisualCalcDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnCalculate();
	afx_msg void OnResetAns();
	afx_msg void OnResetVars();
	afx_msg void OnResetFuncs();
	afx_msg void OnDblclkAnsList();
	afx_msg void OnDblclkFormulasList();
	afx_msg void OnDblclkVarList();
	afx_msg void OnDblclkVarValuesList();
	afx_msg void OnDblclkFuncList();
	afx_msg void OnAbout();
	afx_msg void OnHelp();
	afx_msg void OnChangeInputEdit();
	afx_msg void OnChangeAnswersListState();
	afx_msg void OnChangeVariablesListState();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	void UpdateAnswersList();
	void UpdateVariablesList();
	void UpdateFunctionsList();
	CString RemoveTrailingZeros(const CString&);
	CString InsertThousandSpaces(const CString&);

protected:
	// Window Control pointers
	CEdit*		m_peInput;
	CEdit*		m_peOutput;
	CListBox*	m_plAnswers;
	CListBox*	m_plFormulas;
	CListBox*	m_plVariables;
	CListBox*	m_plVarValues;
	CListBox*	m_plFunctions;
	CButton*	m_pbResetAnswers;
	CButton*	m_pbResetVariables;
	CButton*	m_pbResetFunctions;
	CButton*	m_pbAnswersListState;
	CButton*	m_pbVariablesListState;
	CButton*	m_pbCalculate;
	CButton*	m_pbAbout;
	CButton*	m_pbHelp;
	CStatic*	m_psAnswers;
	CStatic*	m_psVariables;
	CStatic*	m_psFunctions;
	CStatic*	m_psVisualCalc;
	CStatic*	m_psHowToQuit;

	CString		m_strVisualCalcVersion;

	CVCalcParser m_Parser;
};

//{{AFX_INSERT_LOCATION}}
#endif // !defined(__AFX_VISUALCALCDLG_H_INCLUDED__)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Accenture Technology Solutions
France France

Toxcct is an electronics guy who felt in love with programming at the age of 10 when he discovered C to play with Texas-Instruments calculators.

Few years later, he discovered "The C++ Language" from Bjarne Stroustrup ; a true transformation in his life.

Now, toxcct is experiencing the Web by developing Siebel CRM Applications for a living. He also respects very much the Web Standards (YES, a HTML/CSS code MUST validate !), and plays around with HTML/CSS/Javascript/Ajax/PHP and such.

_____

After four years of services as a Codeproject MVP, toxcct is now taking some distance as he doesn't like how things are going on the forums. he particularly doesn't accept how some totally ignorant people got the MVP Reward by only being arrogant and insulting while replying on the technical forums.



Comments and Discussions