Something went wrong. Try again.
A simple, small calculator placed discreetly near the Windows Taskbar or anywhere on the screen taskbar-calculator.marcomaroni.it
Something went wrong. Try again.
taskbar-calculator Calculator.h
1.9 kB · 93 lines
C
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394#pragma once
#define MAX_LEN_RESULT 25
#define CALC_1 _T('1')#define CALC_2 _T('2')#define CALC_3 _T('3')#define CALC_4 _T('4')#define CALC_5 _T('5')#define CALC_6 _T('6')#define CALC_7 _T('7')#define CALC_8 _T('8')#define CALC_9 _T('9')#define CALC_0 _T('0')#define CALC_000 _T('Z')#define CALC_P _T('.')#define CALC_ADD _T('+')#define CALC_SUB _T('-')#define CALC_MUL _T('*')#define CALC_DIV _T('/')#define CALC_SQRT _T('Q')#define CALC_TOT _T('=')#define CALC_RESET _T('N')#define CALC_NEG _T('P')#define CALC_PERC _T('%')#define CALC_I _T('I')
#define CALC_STR_0 _T("0")#define CALC_STR_P _T(".")#define CALC_STR_000 _T("000")
#define ERR_STR_OVERFLOW _T("Error: overflow")#define ERR_STR_DIVBYZERO _T("Error: division by zero")
#ifdef __OS2__class _export calc#elseclass calc#endif{public: calc(); virtual ~calc();
void set_precision(unsigned int precision); unsigned int get_precision();
void change_state(TCHAR newChar, LPCTSTR oldString, LPTSTR newString);
private: enum{ overflow ,division_by_zero };
enum{ undefined_state ,init ,first_oper ,operation ,second_oper ,result ,error }m_prev_state,m_state;
typedef enum _opertors { undefined_oper ,add ,sub ,div ,mul ,calc_sqrt ,percent ,inverse }opertors;
opertors m_operator;
static const int m_max_num_oper; //2 unsigned int m_current_oper; double* m_oper; unsigned int m_precision;
int addChar(LPTSTR string, TCHAR c); int addString(LPTSTR string, LPTSTR str2); int addOper(LPTSTR string); int calcResult(LPTSTR string); int trimRigthDecimalZero(LPTSTR string); void err(int errorCode, LPTSTR string = NULL); int changeToNegative(LPTSTR string);};