Saját munkák
Tudományos számológép teljes forráskódja FileView szerint rendezve (C++)
Implementációs file-ok:
1. // ScientificCalculator.cpp : Defines the class behaviors for the
application.
#include "stdafx.h"
#include "ScientificCalculator.h"
#include "ScientificCalculatorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorApp
BEGIN_MESSAGE_MAP(CScientificCalculatorApp, CWinApp)
//{{AFX_MSG_MAP(CScientificCalculatorApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}} AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorApp construction
CScientificCalculatorApp::CScientificCalculatorApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CScientificCalculatorApp object
CScientificCalculatorApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorApp initialization
BOOL CScientificCalculatorApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
CScientificCalculatorDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
2. ScientificCalculator.hpj
[OPTIONS]
LCID=0x409 0x0 0x0 ;English (U.S.)
TITLE=SCIENTIFICCALCULATOR Application Help
COMPRESS=true
WARNING=2
BMROOT= ..,.
ROOT= ..,.
HLP=ScientificCalculator.HLP
ERRORLOG=ScientificCalculator.LOG
[FILES]
afxdlg.rtf
[ALIAS]
HIDD_ABOUTBOX = HID_APP_ABOUT
HID_HT_SIZE = HID_SC_SIZE
HID_HT_HSCROLL = scrollbars
HID_HT_VSCROLL = scrollbars
HID_HT_MINBUTTON = HID_SC_MINIMIZE
HID_HT_MAXBUTTON = HID_SC_MAXIMIZE
AFX_HIDP_INVALID_FILENAME = AFX_HIDP_default
AFX_HIDP_FAILED_TO_OPEN_DOC = AFX_HIDP_default
AFX_HIDP_FAILED_TO_SAVE_DOC = AFX_HIDP_default
AFX_HIDP_ASK_TO_SAVE = AFX_HIDP_default
AFX_HIDP_FAILED_TO_CREATE_DOC = AFX_HIDP_default
AFX_HIDP_FILE_TOO_LARGE = AFX_HIDP_default
AFX_HIDP_FAILED_TO_START_PRINT = AFX_HIDP_default
AFX_HIDP_FAILED_TO_LAUNCH_HELP = AFX_HIDP_default
AFX_HIDP_INTERNAL_FAILURE = AFX_HIDP_default
AFX_HIDP_COMMAND_FAILURE = AFX_HIDP_default
AFX_HIDP_PARSE_INT = AFX_HIDP_default
AFX_HIDP_PARSE_REAL = AFX_HIDP_default
AFX_HIDP_PARSE_INT_RANGE = AFX_HIDP_default
AFX_HIDP_PARSE_REAL_RANGE = AFX_HIDP_default
AFX_HIDP_PARSE_STRING_SIZE = AFX_HIDP_default
AFX_HIDP_FAILED_INVALID_FORMAT = AFX_HIDP_default
AFX_HIDP_FAILED_INVALID_PATH = AFX_HIDP_default
AFX_HIDP_FAILED_DISK_FULL = AFX_HIDP_default
AFX_HIDP_FAILED_ACCESS_READ = AFX_HIDP_default
AFX_HIDP_FAILED_ACCESS_WRITE = AFX_HIDP_default
AFX_HIDP_FAILED_IO_ERROR_READ = AFX_HIDP_default
AFX_HIDP_FAILED_IO_ERROR_WRITE = AFX_HIDP_default
AFX_HIDP_STATIC_OBJECT = AFX_HIDP_default
AFX_HIDP_FAILED_TO_CONNECT = AFX_HIDP_default
AFX_HIDP_SERVER_BUSY = AFX_HIDP_default
AFX_HIDP_BAD_VERB = AFX_HIDP_default
AFX_HIDP_FAILED_MEMORY_ALLOC = AFX_HIDP_default
AFX_HIDP_FAILED_TO_NOTIFY = AFX_HIDP_default
AFX_HIDP_FAILED_TO_LAUNCH = AFX_HIDP_default
AFX_HIDP_ASK_TO_UPDATE = AFX_HIDP_default
AFX_HIDP_FAILED_TO_UPDATE = AFX_HIDP_default
AFX_HIDP_FAILED_TO_REGISTER = AFX_HIDP_default
AFX_HIDP_FAILED_TO_AUTO_REGISTER = AFX_HIDP_default
[MAP]
#include <C:\Microsoft Visual Studio\VC98\MFC\include\afxhelp.hm>
#include <ScientificCalculator.hm>
3. ScientificCalculator.rc
1.1. Az alkalmazás dialógusablaka
1.2. Az alkalmazás főikonja (egyszerű, saját tervezés)
1.3. Egyéb információs táblázat
4. // ScientificCalculatorDlg.cpp : implementation file
#include "stdafx.h"
#include "ScientificCalculator.h"
#include "ScientificCalculatorDlg.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorDlg dialog
CScientificCalculatorDlg::CScientificCalculatorDlg(CWnd* pParent
/*=NULL*/)
: CDialog(CScientificCalculatorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CScientificCalculatorDlg)
m_display = _T("");
m_inv = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CScientificCalculatorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScientificCalculatorDlg)
DDX_Control(pDX, IDC_BUTTON_X_POWER_3, m_x_power_3);
DDX_Control(pDX, IDC_BUTTON_NOR, m_nor);
DDX_Control(pDX, IDC_BUTTON_EQUIV, m_equiv);
DDX_Control(pDX, IDC_BUTTON_3_ROOT, m_3_root);
DDX_Control(pDX, IDC_BUTTON_MEMWRITE, m_memwrite);
DDX_Control(pDX, IDC_BUTTON_MEMREAD, m_memread);
DDX_Control(pDX, IDC_BUTTON_MEMCLEAR, m_memclear);
DDX_Control(pDX, IDC_BUTTON_PRIME, m_prime);
DDX_Control(pDX, IDC_BUTTON_POINT, m_point);
DDX_Control(pDX, IDC_BUTTON_1_PER_X, m_1_per_x);
DDX_Control(pDX, IDC_BUTTON_X_ROOT, m_x_root);
DDX_Control(pDX, IDC_BUTTON_X_POWER_Y, m_x_power_y);
DDX_Control(pDX, IDC_BUTTON_X_POWER, m_x_power);
DDX_Control(pDX, IDC_BUTTON_TAN, m_tan);
DDX_Control(pDX, IDC_BUTTON_SQUAREROOT, m_squareroot);
DDX_Control(pDX, IDC_BUTTON_SIN, m_sin);
DDX_Control(pDX, IDC_BUTTON_OR, m_or);
DDX_Control(pDX, IDC_BUTTON_NOT, m_not);
DDX_Control(pDX, IDC_BUTTON_MOD, m_mod);
DDX_Control(pDX, IDC_BUTTON_LOG, m_log);
DDX_Control(pDX, IDC_BUTTON_LN, m_ln);
DDX_Control(pDX, IDC_BUTTON_IMP, m_imp);
DDX_Control(pDX, IDC_BUTTON_FACTORIAL, m_factorial);
DDX_Control(pDX, IDC_BUTTON_COS, m_cos);
DDX_Control(pDX, IDC_BUTTON_AND, m_and);
DDX_Control(pDX, IDC_BUTTON_POS_NEG, m_pos_neg);
DDX_Control(pDX, IDC_BUTTON_PI, m_pi);
DDX_Control(pDX, IDC_BUTTON_PERCENT, m_percent);
DDX_Control(pDX, IDC_BUTTON_SUBTRACT, m_subtract);
DDX_Control(pDX, IDC_BUTTON_MULTIPLY, m_multiply);
DDX_Control(pDX, IDC_BUTTON_DIVIDE, m_divide);
DDX_Control(pDX, IDC_BUTTON_ADD, m_add);
DDX_Control(pDX, IDC_BUTTON_EQUAL, m_equal);
DDX_Control(pDX, IDC_BUTTON_9, m_9);
DDX_Control(pDX, IDC_BUTTON_8, m_8);
DDX_Control(pDX, IDC_BUTTON_7, m_7);
DDX_Control(pDX, IDC_BUTTON_6, m_6);
DDX_Control(pDX, IDC_BUTTON_5, m_5);
DDX_Control(pDX, IDC_BUTTON_4, m_4);
DDX_Control(pDX, IDC_BUTTON_3, m_3);
DDX_Control(pDX, IDC_BUTTON_0, m_0);
DDX_Control(pDX, IDC_BUTTON_2, m_2);
DDX_Control(pDX, IDC_BUTTON_1, m_1);
DDX_Text(pDX, IDC_EDIT_DISPLAY, m_display);
DDV_MaxChars(pDX, m_display, 32);
DDX_Check(pDX, IDC_INV, m_inv);
DDX_Control(pDX, IDC_RADIO_DEC, m_radio_dec);
DDX_Control(pDX, IDC_RADIO_BIN, m_radio_bin);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScientificCalculatorDlg, CDialog)
//{{AFX_MSG_MAP(CScientificCalculatorDlg)
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON_2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON_0, OnButton0)
ON_BN_CLICKED(IDC_BUTTON_3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON_4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON_5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON_6, OnButton6)
ON_BN_CLICKED(IDC_BUTTON_7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON_8, OnButton8)
ON_BN_CLICKED(IDC_BUTTON_9, OnButton9)
ON_BN_CLICKED(IDC_BUTTON_EQUAL, OnButtonEqual)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
ON_BN_CLICKED(IDC_BUTTON_POINT, OnButtonPoint)
ON_BN_CLICKED(IDC_BUTTON_BACKSPACE, OnButtonBackspace)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DIVIDE, OnButtonDivide)
ON_BN_CLICKED(IDC_BUTTON_MULTIPLY, OnButtonMultiply)
ON_BN_CLICKED(IDC_BUTTON_POS_NEG, OnButtonPosNeg)
ON_BN_CLICKED(IDC_BUTTON_SUBTRACT, OnButtonSubtract)
ON_BN_CLICKED(IDC_BUTTON_PERCENT, OnButtonPercent)
ON_BN_CLICKED(IDC_BUTTON_PI, OnButtonPi)
ON_BN_CLICKED(IDC_BUTTON_MOD, OnButtonMod)
ON_BN_CLICKED(IDC_BUTTON_X_POWER_Y, OnButtonXPowerY)
ON_BN_CLICKED(IDC_BUTTON_X_POWER, OnButtonXPower)
ON_BN_CLICKED(IDC_BUTTON_SIN, OnButtonSin)
ON_BN_CLICKED(IDC_BUTTON_1_PER_X, OnButton1PerX)
ON_BN_CLICKED(IDC_BUTTON_PRIME, OnButtonPrime)
ON_BN_CLICKED(IDC_BUTTON_SQUAREROOT, OnButtonSquareroot)
ON_BN_CLICKED(IDC_BUTTON_X_ROOT, OnButtonXRoot)
ON_BN_CLICKED(IDC_RADIO_BIN, OnRadioBin)
ON_BN_CLICKED(IDC_BUTTON_X_POWER_3, OnButtonXPower3)
ON_BN_CLICKED(IDC_BUTTON_MEMWRITE, OnButtonMemwrite)
ON_BN_CLICKED(IDC_BUTTON_MEMREAD, OnButtonMemread)
ON_BN_CLICKED(IDC_BUTTON_MEMCLEAR, OnButtonMemclear)
ON_BN_CLICKED(IDC_BUTTON_FACTORIAL, OnButtonFactorial)
ON_BN_CLICKED(IDC_RADIO_DEC, OnRadioDec)
ON_BN_CLICKED(IDC_BUTTON_COS, OnButtonCos)
ON_BN_CLICKED(IDC_BUTTON_LN, OnButtonLn)
ON_BN_CLICKED(IDC_BUTTON_LOG, OnButtonLog)
ON_BN_CLICKED(IDC_BUTTON_TAN, OnButtonTan)
ON_BN_CLICKED(IDC_INV, OnInv)
ON_BN_CLICKED(IDC_BUTTON_IMP, OnButtonImp)
ON_BN_CLICKED(IDC_BUTTON_NOT, OnButtonNot)
ON_BN_CLICKED(IDC_BUTTON_OR, OnButtonOr)
ON_BN_CLICKED(IDC_BUTTON_AND, OnButtonAnd)
ON_BN_CLICKED(IDC_BUTTON_3_ROOT, OnButton3Root)
ON_BN_CLICKED(IDC_BUTTON_EQUIV, OnButtonEquiv)
ON_BN_CLICKED(IDC_BUTTON_NOR, OnButtonNor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorDlg message handlers
BOOL CScientificCalculatorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
m_display = "0";
m_datacontent = FALSE;
DisableWindow();
m_equal.EnableWindow(FALSE);
m_store1 = 0;
m_store2 = 0;
m_opsign = 0;
m_MemStore = 0;
m_ValueStore = 0;
m_inv = FALSE;
m_radio_dec.SetCheck(1); // default decimal
m_DecimalSystem = TRUE;
m_BinarySystem = FALSE;
m_negative = '-';
m_EqualButtonOnce = FALSE;
m_not.EnableWindow(FALSE);
m_equiv.EnableWindow(FALSE);
m_or.EnableWindow(FALSE);
m_nor.EnableWindow(FALSE);
m_and.EnableWindow(FALSE);
m_imp.EnableWindow(FALSE);
UpdateData (FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CScientificCalculatorDlg::OnDestroy()
{
WinHelp(0L, HELP_QUIT);
CDialog::OnDestroy();
}
// 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 CScientificCalculatorDlg::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 CScientificCalculatorDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CScientificCalculatorDlg::OnButton1()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "1";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "1";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "1";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton2()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "2";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "2";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "2";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton0()
{
if (m_display.GetLength() > 31)
return;
else if (m_datacontent == FALSE)
{
m_display.Empty();
m_display = "0";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0') &&
(m_datacontent == TRUE))
return;
else
{
m_display += "0";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
}
void CScientificCalculatorDlg::OnButton3()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "3";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "3";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "3";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton4()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "1";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "1";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "1";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton5()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "5";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "5";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "5";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton6()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "6";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "6";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "6";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton7()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "7";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "7";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "7";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton8()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "8";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "8";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "8";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButton9()
{
if (m_display.GetLength() > 31)
return;
else if ((m_display.GetLength() == 1) && (m_display.GetAt(0) == '0'))
{
m_display.Empty ();
m_display = "9";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else if (m_datacontent == FALSE)
{
m_display.Empty ();
m_display = "9";
m_datacontent = TRUE;
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display += "9";
if (m_BinarySystem == TRUE)
{
DisableWindow();
m_equal.EnableWindow(TRUE);
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
EnableWindow();
UpdateData(FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButtonEqual()
{
switch (m_opsign)
{
case '+': m_store1 += m_store2; break; // add
case '-': m_store1 -= m_store2; break; // subtract
case '*': // multiply
{
if ((m_store1 == 0) || (m_store2 == 0))
{
AfxMessageBox ("One of your datas is 0.\nThe operation actually is
senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store1 *= m_store2;
} break;
case '/': // divide
{
if ((m_store1 == 0) || (m_store2 == 0))
{
AfxMessageBox ("One of your datas is 0.\nThe operation actually is
senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store1 /= m_store2;
} break;
case '%': // percentage
{
if (m_EqualButtonOnce == TRUE)
return;
else if ((m_store1 == 0) || (m_store2 == 0))
{
AfxMessageBox ("One of your datas is 0.\nThe operation actually is
senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store1 = (m_store1 / 100) * m_store2;
} break;
case 'm': // remainder, modulus
{
if (m_EqualButtonOnce == TRUE)
return;
else if (m_inv == TRUE)
{
AfxMessageBox ("Senseless indication(s).",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if ((m_store1 == 0) || (m_store2 == 0))
{
AfxMessageBox ("One of your datas is 0.\nThe operation actually is
senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_store1 < m_store2)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if ((m_store1 < 1 ) || (m_store2 < 1))
{
AfxMessageBox ("One of your datas is < 1.\nThe operation is senseless.",
MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
{
int m_StoreValue = (int)m_store1;
m_store1 = m_StoreValue % int(m_store2); // casting m_store2
if (m_store1 == 0)
{
AfxMessageBox ("No modulus (remainder)", MB_OK | MB_ICONINFORMATION);
OnButtonClear(); // Pénzes-jegyzet: this is because do not let the same
result (mod = 0) indicate in separate ways
return;
}
else
UpdateData(FALSE);
}
} break;
case 'p': // x_power_y
{
double m_StoreValue = m_store1;
if (m_EqualButtonOnce == TRUE)
return;
else if (m_inv == TRUE) // if inverse: x_root
{
m_opsign = 'x';
m_inv = FALSE;
OnButtonEqual();
return;
}
else if ((m_store1 == 1) || (m_store2 == 0))
m_store1 = 1;
else
m_store1 = pow(m_store1, m_store2); // Pénzes-jegyzet: raising to power,
also handles exp. -1, -2, etc.
} break;
case 'x': // x_root
{
double m_StoreValue = m_store1;
if (m_EqualButtonOnce == TRUE)
return;
else if ((m_store1 <= 0) || (m_store2 <= 0))
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_inv == TRUE) // if inverse: x_power_y
{
m_opsign = 'p';
m_inv = FALSE;
OnButtonEqual();
return;
}
else
m_StoreValue = 1 / m_store2;
m_store1 = pow(m_store1, m_StoreValue);
} break;
//logical ops
case '&': // logical AND
{
if (m_display.GetLength() > 1) // m_store2
{
AfxMessageBox ("For the exam of logical operations is\nonly necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_store1 == 1) && (m_store2 == 1))
{
LogicalTRUE();
return;
}
else
{
LogicalFALSE();
return;
}
} break;
case 'o': // logical OR
{
if (m_display.GetLength() > 1) // m_store2
{
AfxMessageBox ("For the exam of logical operations is\nonly necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_store1 == 1) || (m_store2 == 1))
{
LogicalTRUE();
return;
}
else
{
LogicalFALSE();
return;
}
} break;
case 'n': // logical NOR
{
if (m_display.GetLength() > 1) // m_store2
{
AfxMessageBox ("For the exam of logical operations is\nonly necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_store1 == 0) && (m_store2 == 0))
{
LogicalTRUE();
return;
}
else
{
LogicalFALSE();
return;
}
} break;
case 'i': // logical IMP
{
if (m_display.GetLength() > 1) // m_store2
{
AfxMessageBox ("For the exam of logical operations is\nonly necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_store1 == 1) && (m_store2 == 0))
{
LogicalFALSE();
return;
}
else
{
LogicalTRUE();
return;
}
} break;
case 'e': // logical EQUIVALENCE
{
if (m_display.GetLength() > 1) // m_store2
{
AfxMessageBox ("For the exam of logical operations is\nonly necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if (m_store1 == m_store2)
{
LogicalTRUE();
return;
}
else
{
LogicalFALSE();
return;
}
} break;
default: break;
}
Displaying();
}
void CScientificCalculatorDlg::OnButtonClear()
{
m_display.Empty ();
m_display = "0";
m_datacontent = FALSE;
m_EqualButtonOnce = FALSE;
m_inv = FALSE;
DisableWindow();
m_equal.EnableWindow(FALSE);
m_store1 = 0;
m_store2 = 0;
m_opsign = 0;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonPoint()
{
if (m_display.Find ( '.', 0 ) == -1) // Pénzes-jegyzet: if is not found
{
m_display += ".";
UpdateData (FALSE);
}
else
return;
}
void CScientificCalculatorDlg::OnButtonBackspace()
{
if ((m_display.GetLength () == 1) && (m_display.GetAt (0) == '0'))
{
return;
}
else if ((m_display.GetLength () == 1) && (m_display.GetAt (0) != '0'))
{
m_datacontent = FALSE;
m_display = "0";
UpdateData (FALSE);
return;
}
else
m_display = m_display.Left (m_display.GetLength () -1);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonAdd()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = '+';
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '+';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = '+';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonDivide()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = '/';
OnButtonEqual ();
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '/';
return;
}
else
{
m_store1 = atof (m_display.operator LPCTSTR ());
}
m_opsign = '/';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonMultiply()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = '*';
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '*';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = '*';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonPosNeg()
{
if ((m_display.GetLength () == 1) && (m_display.GetAt (0) == '0'))
{
return;
}
else if (m_display.Find ( '-', 0 ) == -1) // if not found
{
m_display = m_negative + m_display;
UpdateData (FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
else
m_display = m_display.Right (m_display.GetLength () -1);
UpdateData (FALSE);
m_store2 = atof (m_display.operator LPCTSTR ());
return;
}
void CScientificCalculatorDlg::OnButtonSubtract()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = '-';
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '-';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = '-';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
m_EqualButtonOnce = FALSE;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonPercent()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = '%';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '%';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = '%';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonPi()
{
// Pénzes-jegyzet: pi = 3.1415926535897932384626433832795
m_display.Empty ();
m_display = "3.1415926535897932384626433832";
m_store2 = atof (m_display.operator LPCTSTR ());
m_datacontent = TRUE;
EnableWindow();
UpdateData (FALSE);
}
void CScientificCalculatorDlg::EnableWindow()
{
m_add.EnableWindow(TRUE);
m_divide.EnableWindow(TRUE);
m_subtract.EnableWindow(TRUE);
m_multiply.EnableWindow(TRUE);
m_equal.EnableWindow(TRUE);
m_percent.EnableWindow(TRUE);
m_pos_neg.EnableWindow(TRUE);
m_x_power_y.EnableWindow(TRUE);
m_mod.EnableWindow(TRUE);
m_prime.EnableWindow(TRUE);
m_1_per_x.EnableWindow(TRUE);
m_factorial.EnableWindow(TRUE);
m_ln.EnableWindow(TRUE);
m_log.EnableWindow(TRUE);
m_mod.EnableWindow(TRUE);
m_point.EnableWindow(TRUE);
m_sin.EnableWindow(TRUE);
m_cos.EnableWindow(TRUE);
m_tan.EnableWindow(TRUE);
m_squareroot.EnableWindow(TRUE);
m_x_root.EnableWindow(TRUE);
m_x_power.EnableWindow(TRUE);
m_3_root.EnableWindow(TRUE);
m_x_power_3.EnableWindow(TRUE);
}
void CScientificCalculatorDlg::OnButtonMod()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = 'm';
OnButtonEqual ();
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'm';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'm';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonXPowerY()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = 'p';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'p';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'p';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonXPower()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_inv == TRUE)
{
m_store1 = sqrt(m_StoreValue);
Displaying();
return;
}
else
m_store1 *= m_StoreValue;
OnButtonEqual ();
}
void CScientificCalculatorDlg::OnButtonSin()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_inv == TRUE)
{
m_store1 = asin(m_StoreValue); // arcus if inv
m_store1 = m_store1 * 360/(2*3.1415926535897932384626433832795);
Displaying();
return;
}
else
{
m_StoreValue = m_StoreValue * (2*3.1415926535897932384626433832795/360);
m_store1 = sin(m_StoreValue);
Displaying();
}
}
void CScientificCalculatorDlg::OnButton1PerX()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_store1 == 0)
{
AfxMessageBox ("Absolutely senseless operation.",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_inv == TRUE)
{
AfxMessageBox ("Senseless operation.\nThe result is identical with the
value.",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store1 = 1 / m_StoreValue;
OnButtonEqual ();
}
void CScientificCalculatorDlg::OnButtonPrime()
{
double last = 0;
int m_primestore = 0;
int i = 3;
m_equal.EnableWindow(FALSE);
if ((m_display.Find ( '.', 0 ) != -1)) // Pénzes-jegyzet: if is found
{
AfxMessageBox ("The value must be an integer for exam",MB_OK | MB_ICONEXCLAMATION);
// Pénzes-jegyzet: need exclamation mark & button OK: MB_ICONEXCLAMATION,
MB_OK
OnButtonClear();
return;
}
else if (m_inv == TRUE)
{
AfxMessageBox ("Senseless indication(s).",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else m_primestore = atoi (m_display.operator LPCTSTR ());
if (m_primestore == 0)
{
AfxMessageBox ("The value must be an integer for exam.",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_primestore == 1)
{
AfxMessageBox ("NOT Primenumber",MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if (m_primestore == 2)
{
AfxMessageBox ("Primenumber",MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_primestore != 2) && (m_primestore % 2 == 0))
{
AfxMessageBox ("NOT primenumber",MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else
{
last = sqrt(m_primestore);
for (i; i <= last; i++)
{
if ((m_primestore % i) == 0)
{
AfxMessageBox ("NOT primenumber",MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else
continue;
}
AfxMessageBox ("Primenumber",MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
}
void CScientificCalculatorDlg::OnButtonSquareroot()
{
m_store1 = atof (m_display.operator LPCTSTR ());
m_equal.EnableWindow(FALSE);
double m_StoreValue = m_store1;
if (m_store1 <= 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_inv == TRUE)
{
m_store1 *= m_StoreValue;
Displaying();
return;
}
else
m_store1 = sqrt(m_StoreValue);
Displaying();
}
void CScientificCalculatorDlg::OnButtonXRoot()
{
if ((m_opsign != 0) && (m_datacontent == TRUE))
{
OnButtonEqual ();
m_opsign = 'x';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'x';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'x';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnRadioBin()
{
if ((m_display.Find ( '.', 0 ) != -1)) // Pénzes-jegyzet: if is found
{
AfxMessageBox ("The value must be an integer for exam",MB_OK | MB_ICONEXCLAMATION);
m_BinarySystem = FALSE;
m_DecimalSystem = TRUE;
OnButtonClear();
m_radio_dec.SetCheck(1);
m_radio_bin.SetCheck(0);
OnRadioDec();
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
if (m_store1 > 4294967295) // 32 db 1-es the max.
{
AfxMessageBox ("The result is too big.", MB_OK | MB_ICONINFORMATION);
m_BinarySystem = FALSE;
m_DecimalSystem = TRUE;
OnButtonClear();
m_radio_dec.SetCheck(1);
m_radio_bin.SetCheck(0);
OnRadioDec();
return;
}
else
m_BinarySystem = TRUE;
m_DecimalSystem = FALSE;
m_2.EnableWindow(FALSE);
m_3.EnableWindow(FALSE);
m_4.EnableWindow(FALSE);
m_5.EnableWindow(FALSE);
m_6.EnableWindow(FALSE);
m_7.EnableWindow(FALSE);
m_8.EnableWindow(FALSE);
m_9.EnableWindow(FALSE);
m_point.EnableWindow(FALSE);
m_pi.EnableWindow(FALSE);
DisableWindow();
m_equal.EnableWindow(FALSE);
m_not.EnableWindow(TRUE);
m_or.EnableWindow(TRUE);
m_and.EnableWindow(TRUE);
m_imp.EnableWindow(TRUE);
m_equiv.EnableWindow(TRUE);
m_nor.EnableWindow(TRUE);
m_inv = FALSE;
ConversionFromDecimalIntoBinary();
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonXPower3()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
int i = 1;
if (m_inv == TRUE)
{
if (m_store1 < 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
{
m_store2 = 3;
m_StoreValue = 1 / m_store2;
m_store1 = pow(m_store1, m_StoreValue);
Displaying();
return;
}
}
else
for (i; i < 3; i++)
{
m_store1 *= m_StoreValue;
}
OnButtonEqual ();
}
void CScientificCalculatorDlg::OnButtonMemwrite()
{
m_MemStore = atof (m_display.operator LPCTSTR ());
if (m_MemStore == 0)
{
AfxMessageBox ("Storing 0 is senseless.",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store2 = m_MemStore;
return;
}
void CScientificCalculatorDlg::OnButtonMemread()
{
if (m_MemStore == 0)
{
AfxMessageBox ("Value no stored.",MB_OK | MB_ICONINFORMATION);
return;
}
else
m_store2 = m_MemStore;
m_display.Format("%f",m_MemStore);
m_datacontent = TRUE;
EnableWindow();
UpdateData(FALSE);
}
void CScientificCalculatorDlg::OnButtonMemclear()
{
if (m_MemStore == 0)
{
AfxMessageBox ("Value no stored.",MB_OK | MB_ICONINFORMATION);
return;
}
else
m_MemStore = 0;
AfxMessageBox ("Memory cleared.",MB_OK | MB_ICONINFORMATION);
}
void CScientificCalculatorDlg::OnButtonFactorial()
{
int i = 1;
double m_StoreValue;
m_equal.EnableWindow(FALSE);
if (m_inv == TRUE)
{
AfxMessageBox ("Senseless indication(s).",MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_store1 < 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
if ((m_store1 == 0) || (m_store1 == 1))
{
m_display = "1";
UpdateData (FALSE);
return;
}
else
m_StoreValue = 1;
for (i; i <= m_store1; i++)
{
m_StoreValue*=i;
}
m_store1 = m_StoreValue;
Displaying();
}
void CScientificCalculatorDlg::ConversionFromDecimalIntoBinary()
{
int ValueStoreAtBinary = 0;
char Display [35];
m_ValueStore = atof (m_display.operator LPCTSTR ());
ValueStoreAtBinary = (int)m_ValueStore;
itoa (ValueStoreAtBinary, Display, 2); // char *_i64toa( __int64 value,
char *string, int radix)
m_display = Display;
}
void CScientificCalculatorDlg::OnRadioDec()
{
m_pi.EnableWindow(TRUE);
m_2.EnableWindow(TRUE);
m_3.EnableWindow(TRUE);
m_4.EnableWindow(TRUE);
m_5.EnableWindow(TRUE);
m_6.EnableWindow(TRUE);
m_7.EnableWindow(TRUE);
m_8.EnableWindow(TRUE);
m_9.EnableWindow(TRUE);
m_not.EnableWindow(FALSE);
m_equiv.EnableWindow(FALSE);
m_or.EnableWindow(FALSE);
m_nor.EnableWindow(FALSE);
m_and.EnableWindow(FALSE);
m_imp.EnableWindow(FALSE);
m_equal.EnableWindow(FALSE);
m_inv = FALSE;
if (m_DecimalSystem == TRUE)
{
OnButtonClear();
return;
}
else if (m_BinarySystem == TRUE) // conv. binary into decimal
{
m_BinarySystem = FALSE;
m_DecimalSystem = TRUE;
m_ValueStore = atof (m_display.operator LPCTSTR ());
if (m_ValueStore == 0)
{
m_display = "0";
UpdateData(FALSE);
return;
}
else
{
double m_value = 0;
int m_length = m_display.GetLength()-1;
for(int i = m_length; i >= 0; i--)
{
if (m_display[i]=='0')
{
continue;
}
m_value += pow(2, m_length-i);
}
m_store1 = m_value;
Displaying();
UpdateData (FALSE);
return;
}
}
else
m_BinarySystem = FALSE;
m_DecimalSystem = TRUE;
m_display.Format("%d",m_ValueStore);
UpdateData(FALSE);
}
void CScientificCalculatorDlg::DisableWindow()
{
m_add.EnableWindow(FALSE);
m_divide.EnableWindow(FALSE);
m_subtract.EnableWindow(FALSE);
m_multiply.EnableWindow(FALSE);
m_percent.EnableWindow(FALSE);
m_pos_neg.EnableWindow(FALSE);
m_x_power_y.EnableWindow(FALSE);
m_mod.EnableWindow(FALSE);
m_prime.EnableWindow(FALSE);
m_1_per_x.EnableWindow(FALSE);
m_factorial.EnableWindow(FALSE);
m_ln.EnableWindow(FALSE);
m_log.EnableWindow(FALSE);
m_mod.EnableWindow(FALSE);
m_point.EnableWindow(FALSE);
m_sin.EnableWindow(FALSE);
m_cos.EnableWindow(FALSE);
m_tan.EnableWindow(FALSE);
m_squareroot.EnableWindow(FALSE);
m_x_root.EnableWindow(FALSE);
m_x_power.EnableWindow(FALSE);
m_3_root.EnableWindow(FALSE);
m_x_power_3.EnableWindow(FALSE);
}
void CScientificCalculatorDlg::OnButtonCos()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_inv == TRUE)
{
m_store1 = acos(m_StoreValue);
m_store1 = m_store1 * 360/(2*3.1415926535897932384626433832795);
Displaying();
return;
}
else
{
m_StoreValue = m_StoreValue * (2*3.1415926535897932384626433832795/360);
m_store1 = cos(m_StoreValue);
Displaying();
}
}
void CScientificCalculatorDlg::OnButtonLn()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_store1 <= 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
{
if (m_inv == TRUE)
{
m_store1 = exp(m_StoreValue);
Displaying();
return;
}
else
{
m_store1 = log(m_StoreValue);
Displaying();
}
}
}
void CScientificCalculatorDlg::OnButtonLog()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_store1 <= 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_inv == TRUE)
{
m_store1 = pow(10, m_StoreValue);
Displaying();
return;
}
else
m_store1 = log10(m_StoreValue);
Displaying();
}
void CScientificCalculatorDlg::OnButtonTan()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
if (m_inv == TRUE)
{
m_store1 = atan(m_StoreValue); // if inv
m_StoreValue = 2*m_StoreValue /360* 3.1415926535897932384626433832795;
Displaying();
return;
}
else if (m_store1 == 90)
{
AfxMessageBox ("Operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else if (m_store1 == 180)
{
m_display = "0";
UpdateData(FALSE);
return;
}
else
m_StoreValue = 2*m_StoreValue /360* 3.1415926535897932384626433832795;
m_store1 = tan(m_StoreValue);
Displaying();
}
void CScientificCalculatorDlg::OnInv()
{
if (m_BinarySystem == TRUE)
{
AfxMessageBox ("Senseless indication.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else
m_inv = TRUE;
}
void CScientificCalculatorDlg::Displaying()
{
if (m_display.GetLength() > 31)
{
AfxMessageBox ("The result is too big.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if (m_store1 == 0.0)
{
m_display = "0";
m_datacontent = FALSE;
m_EqualButtonOnce = TRUE;
m_inv = FALSE;
UpdateData (FALSE);
return;
}
else
m_display.Format("%f",m_store1);
int length = m_display.GetLength(), i;
for(i = length-1; i >= 0; i--)
{
if(m_display.GetAt(i) == '0')
continue;
else
break;
}
if (m_display.GetAt(i) == '.')
i--;
m_display = m_display.Left(i + 1);
m_datacontent = FALSE;
m_EqualButtonOnce = TRUE;
m_inv = FALSE;
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonImp()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = 'i';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'i';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'i';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonNot()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
if (m_store1 == 1)
{
LogicalFALSE();
return;
}
else
LogicalTRUE();
}
void CScientificCalculatorDlg::OnButtonOr()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = 'o';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'o';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'o';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonAnd()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = '&';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = '&';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = '&';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButton3Root()
{
m_store1 = atof (m_display.operator LPCTSTR ());
double m_StoreValue = m_store1;
m_equal.EnableWindow(FALSE);
int i = 1;
if (m_inv == TRUE)
{
if (m_store1 < 0)
{
AfxMessageBox ("The operation is senseless.", MB_OK | MB_ICONEXCLAMATION);
OnButtonClear();
return;
}
else
{
m_store1 = pow(m_store1, 3);
Displaying();
UpdateData(FALSE);
return;
}
}
else
m_store2 = 3;
m_StoreValue = 1 / m_store2;
m_store1 = pow(m_store1, m_StoreValue);
Displaying();
}
void CScientificCalculatorDlg::LogicalTRUE()
{
AfxMessageBox ("The result of this operation\n is TRUE (1).", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
}
void CScientificCalculatorDlg::LogicalFALSE()
{
AfxMessageBox ("The result of this operation\n is FALSE (0).", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
}
void CScientificCalculatorDlg::OnButtonEquiv()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = 'e';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'e';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'e';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
void CScientificCalculatorDlg::OnButtonNor()
{
if (m_display.GetLength() > 1)
{
AfxMessageBox ("For the exam of logical operations\nis only necessary one
digit: 1 or 0.", MB_OK | MB_ICONINFORMATION);
OnButtonClear();
return;
}
else if ((m_opsign != 0) && (m_datacontent == TRUE))
{
m_opsign = 'n';
UpdateData (FALSE);
return;
}
else if ((m_opsign != 0) && (m_datacontent == FALSE))
{
m_opsign = 'n';
return;
}
else
m_store1 = atof (m_display.operator LPCTSTR ());
m_opsign = 'n';
m_datacontent = FALSE;
m_equal.EnableWindow(TRUE);
UpdateData (FALSE);
}
5. // stdafx.cpp : source file that includes just the standard includes
// ScientificCalculator.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h
Header file-ok:
1. // Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ScientificCalculator.rc
//
#define IDD_SCIENTIFICCALCULATOR_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_BUTTON_0 1000
#define IDC_BUTTON_2 1001
#define IDC_BUTTON_1 1002
#define IDC_BUTTON_3 1003
#define IDC_BUTTON_7 1004
#define IDC_BUTTON_ADD 1005
#define IDC_BUTTON_4 1006
#define IDC_BUTTON_5 1007
#define IDC_BUTTON_6 1008
#define IDC_BUTTON_EQUAL 1009
#define IDC_EDIT_DISPLAY 1010
#define IDC_BUTTON_8 1011
#define IDC_BUTTON_9 1012
#define IDC_BUTTON_CLEAR 1013
#define IDC_BUTTON_POINT 1014
#define IDC_BUTTON_BACKSPACE 1015
#define IDC_BUTTON_MULTIPLY 1016
#define IDC_BUTTON_SUBTRACT 1017
#define IDC_BUTTON_DIVIDE 1018
#define IDC_BUTTON_POS_NEG 1019
#define IDC_BUTTON_IMP 1020
#define IDC_BUTTON_SIN 1021
#define IDC_BUTTON_COS 1022
#define IDC_BUTTON_TAN 1023
#define IDC_BUTTON_CTG 1024
#define IDC_BUTTON_X_POWER_3 1024
#define IDC_BUTTON_FACTORIAL 1025
#define IDC_BUTTON_PER_X 1026
#define IDC_BUTTON_1_PER_X 1026
#define IDC_BUTTON_SQUAREROOT 1027
#define IDC_BUTTON_X_ROOT 1028
#define IDC_BUTTON_LN 1029
#define IDC_BUTTON_LOG 1030
#define IDC_BUTTON_PI 1031
#define IDC_INV 1032
#define IDC_BUTTON_X_POWER 1033
#define IDC_BUTTON_X_POWER_Y 1034
#define IDC_BUTTON_MEMCLEAR 1035
#define IDC_BUTTON_MEMREAD 1036
#define IDC_BUTTON_MEMWRITE 1037
#define IDC_DEC 1038
#define IDC_RADIO_DEC 1038
#define IDC_RADIO_BIN 1039
#define IDC_RADIO_HEX 1040
#define IDC_BUTTON_3_ROOT 1040
#define IDC_RADIO_OCT 1041
#define IDC_BUTTON_HEX_10 1042
#define IDC_BUTTON_HEX_11 1043
#define IDC_BUTTON_HEX_12 1044
#define IDC_BUTTON_HEX_13 1045
#define IDC_BUTTON_HEX_14 1046
#define IDC_BUTTON_HEX_15 1047
#define IDC_BUTTON_NOT 1048
#define IDC_BUTTON_OR 1049
#define IDC_BUTTON_AND 1050
#define IDC_BUTTON_XOR 1051
#define IDC_BUTTON_EQUIV 1051
#define IDC_HYP 1052
#define IDC_BUTTON_PERCENT 1053
#define IDC_BUTTON_MOD 1054
#define IDC_BUTTON_PRIME 1055
#define IDC_BUTTON_NOR 1056
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1057
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
2. // ScientificCalculator.h : main header file for the SCIENTIFICCAL.
application
//
#if !defined(AFX_SCIENTIFICCALCULATOR_H__814E3733_B92D_4DEA_BCFD_48E62A33E616__INCLUDED_)
#define AFX_SCIENTIFICCALCULATOR_H__814E3733_B92D_4DEA_BCFD_48E62A33E616__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorApp:
// See ScientificCalculator.cpp for the implementation of this class
//
class CScientificCalculatorApp : public CWinApp
{
public:
CScientificCalculatorApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScientificCalculatorApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CScientificCalculatorApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
#endif
// !defined(AFX_SCIENTIFICCALCULATOR_H__814E3733_B92D_4DEA_BCFD_48E62A33E616__INCLUDED_)
3. // ScientificCalculatorDlg.h : header file
#if !defined(AFX_SCIENTIFICCALCULATORDLG_H__36CD5E2B_7E0B_46C7_9F32_B1F0D82D732B__INCLUDED_)
#define AFX_SCIENTIFICCALCULATORDLG_H__36CD5E2B_7E0B_46C7_9F32_B1F0D82D732B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CScientificCalculatorDlg dialog
class CScientificCalculatorDlg : public CDialog
{
// Construction
public:
double m_ValueStore;
void LogicalFALSE();
void LogicalTRUE();
void Displaying();
void DisableWindow();
bool m_BinarySystem;
bool m_DecimalSystem;
void ConversionFromDecimalIntoBinary();
double m_MemStore;
bool m_EqualButtonOnce;
char m_negative;
char m_opsign;
BOOL m_datacontent;
double m_store2;
double m_store1;
CScientificCalculatorDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CScientificCalculatorDlg)
enum { IDD = IDD_SCIENTIFICCALCULATOR_DIALOG };
CButton m_x_power_3;
CButton m_nor;
CButton m_equiv;
CButton m_3_root;
CButton m_memwrite;
CButton m_memread;
CButton m_memclear;
CButton m_prime;
CButton m_point;
CButton m_1_per_x;
CButton m_x_root;
CButton m_x_power_y;
CButton m_x_power;
CButton m_tan;
CButton m_squareroot;
CButton m_sin;
CButton m_or;
CButton m_not;
CButton m_mod;
CButton m_log;
CButton m_ln;
CButton m_imp;
CButton m_factorial;
CButton m_cos;
CButton m_and;
CButton m_pos_neg;
CButton m_pi;
CButton m_percent;
CButton m_subtract;
CButton m_multiply;
CButton m_divide;
CButton m_add;
CButton m_equal;
CButton m_9;
CButton m_8;
CButton m_7;
CButton m_6;
CButton m_5;
CButton m_4;
CButton m_3;
CButton m_0;
CButton m_2;
CButton m_1;
CString m_display;
BOOL m_inv;
CButton m_radio_dec;
CButton m_radio_bin;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScientificCalculatorDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void EnableWindow();
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CScientificCalculatorDlg)
virtual BOOL OnInitDialog();
afx_msg void OnDestroy();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButton1();
afx_msg void OnButton2();
afx_msg void OnButton0();
afx_msg void OnButton3();
afx_msg void OnButton4();
afx_msg void OnButton5();
afx_msg void OnButton6();
afx_msg void OnButton7();
afx_msg void OnButton8();
afx_msg void OnButton9();
afx_msg void OnButtonEqual();
afx_msg void OnButtonClear();
afx_msg void OnButtonPoint();
afx_msg void OnButtonBackspace();
afx_msg void OnButtonAdd();
afx_msg void OnButtonDivide();
afx_msg void OnButtonMultiply();
afx_msg void OnButtonPosNeg();
afx_msg void OnButtonSubtract();
afx_msg void OnButtonPercent();
afx_msg void OnButtonPi();
afx_msg void OnButtonMod();
afx_msg void OnButtonXPowerY();
afx_msg void OnButtonXPower();
afx_msg void OnButtonSin();
afx_msg void OnButton1PerX();
afx_msg void OnButtonPrime();
afx_msg void OnButtonSquareroot();
afx_msg void OnButtonXRoot();
afx_msg void OnRadioBin();
afx_msg void OnButtonXPower3();
afx_msg void OnButtonMemwrite();
afx_msg void OnButtonMemread();
afx_msg void OnButtonMemclear();
afx_msg void OnButtonFactorial();
afx_msg void OnRadioDec();
afx_msg void OnButtonCos();
afx_msg void OnButtonLn();
afx_msg void OnButtonLog();
afx_msg void OnButtonTan();
afx_msg void OnInv();
afx_msg void OnButtonImp();
afx_msg void OnButtonNot();
afx_msg void OnButtonOr();
afx_msg void OnButtonAnd();
afx_msg void OnButton3Root();
afx_msg void OnButtonEquiv();
afx_msg void OnButtonNor();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
#endif // !defined(AFX_SCIENTIFICCALCULATORDLG_H__36CD5E2B_7E0B_46C7_9F32_B1F0D82D732B__INCLUDED_)
4. // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__C1A1F260_33C6_4D8E_9CC8_2F3B6109297B__INCLUDED_)
#define AFX_STDAFX_H__C1A1F260_33C6_4D8E_9CC8_2F3B6109297B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common
Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
#endif // !defined(AFX_STDAFX_H__C1A1F260_33C6_4D8E_9CC8_2F3B6109297B__INCLUDED_)
Erőforrás file-ok:
1. ScientificCalculator.ico
Az alkalmazás már említett főikonja.
2. // ScientificCalculator.rc2 - resources Microsoft Visual C++ does not
edit directly
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
Help-file-ok:
1. AfxDlg.rtf
# <<Scientific Calculator Help File>>
A kijelzőbe maximum 32 karaktar írható. Ebbe esetlegesen beletartozik a
tizedesjel és a mínusz jel karakter is.
A kijelzőbe egyéb karakter nem vihető be.
Nsystem – számrendszer
Két számrendszer érhető el az alkalmazásban: a decimális és a bináris.
Mindegyik átváltható egymásba, de bináris számrendszer esetén csak a
logikai műveletek vizsgálata lehetséges. A logikai műveletek a NOT
kivételével mind kétoperandusú műveletek és vizsgálatukhoz elég egy
számjegy beírása, 1 vagy 0.
X power – szám négyzetre emelése
Például: 2 x power = 4.
X power y – szám y-ra emelése
Például: 2 x power 4 = 16.
Square root – szám négyzetgyöke
Például: 4 square root = 2.
X root – szám x-edik gyöke
Például: 16 x root 4 = 2.
Ln – szám természetes alapú logaritmusa
Például: 2 ln = 0.693147...
Log – szám tizes alapú logaritmusa
Például: 10 log = 1.
1/x – szám inverze, azaz egy osztva a számmal
Prime? – szám prímszám?
Azt vizsgálja, hogy a bevitt szám prímszám-e.
Például: 5 Prime? = üzenetablak: Primenumber.
Mod – maradékképzés
Azt vizsgálja, hogy mennyi két szám osztásakor keletkező maradék.
Például: 5 mod 4 = 1.
Sin – szám színusza
A mértékegység fok. Például: 90 (fok) sin = 1. Inv esetén színuszt vált át
fokba.
Cos – szám koszínusza
A mértékegység fok. Például: 90 (fok) cos = 0. Inv esetén koszínuszt vált
át fokba.
Tan – szám tangense
A mértékegység fok. Például: 45 (fok) tan = 1. Inv esetén tangenst vált át
fokba.
n! – szám faktoriális számítása
Például: 5 n! = 120.
Pi szám
3.1415926535897932384626433832795.
Inverse – inverz, a művelet megfordítása
Például: 2 x power 3 = 8, 8 Inv x power 3 = 2, azaz 8 köbgyöke 2.
Memory write – szám tárolása a memóriában
Memory read – szám kiolvasása a memóriából
Memory clear – szám törlése a memóriából
Backspace – visszaléptetés
Törli a legutoljára bevitt számjegyet.
Clear – törlés
A memóriába betett szám kivételével minden bevitt adatot töröl vagy
nulláz.
Előjelváltás - +/-
Az alapértelmezés a pozitív számokkal való számítások.
Először a számot kell betenni, majd utána az előjelet. Az előjelváltó gomb
újbóli megnyomásával a szám ismét pozitívvá válik.
Logikai műveletek
NOT – logikai NEM.
OR – logikai VAGY.
NOR – logikai “NEMVAGY”.
AND – logikai ÉS.
EQUI – logikai EGYENÉRTÉKŰSÉG.
IMP – logikai IMPLIKÁCIÓ.
Hiba-, és egyéb üzenetek
Senseless indication. – Értelmetlen jelölés.
Absolutely senseless operation. – Teljességgel értelmetlen művelet (mert a
0-val való osztás az).
Senseless operation. The result is identical with the value. – Értelmetlen
művelet. Az eredmény azonos a bevitt adattal.
One of your datas is 0. The operation actually is senseless. – Az egyik
adat 0. A művelet valójában értelmetlen.
One of your datas is < 1. The operation actually is senseless. – Az egyik
adat kisebb 1-nél. A művelet valójában értelmetlen.
No modulus (remainder) – Nincs maradék.
For the exam of logical operations is only necessary one digit: 1 or 0. –
A logikai műveletek vizsgálatához elég egy számjegy: 1 vagy 0.
The value must be an integer for exam. – Az adatnak a vizsgálathoz egész
számnak kell lennie.
Primenumber – Prímszám.
NOT Primenumber – Nem prímszám.
Storing 0 is senseless. – 0 tárolása értelmetlen.
Value no stored. – Érték nem lett tárolva.
Memory cleared. – Memória törölve.
The result of this operation is TRUE (1). – A művelet eredménye IGAZ (1).
The result of this operation is FALSE (0). – A művelet eredménye HAMIS
(0).
The result is too big. – Az eredmény túl nagy.
Köszönöm alkotó segítségét Balázs Gyula mérnök-programozónak és Czinege
Katalin matematika tanárnak!
2. ScientificCalculator.cnt
:Base ScientificCalculator.hlp
1 <<add your topic jumps here>>=HIDD_SCIENTIFICCALCULATOR_DIALOG
3. ReadMe.txt
Az alkalmazás felépítése során keletkező file-ok egyszerű magyarázata. Ezt
én már az előző fejezetekben megtettem, ezért úgy gondolom részletezése
felesleges.
Külső dependenciák:
1. basetsd.h
#ifndef _BASETSD_H_
#define _BASETSD_H_
#ifdef __cplusplus
extern "C" {
#endif
//
// The following types are guaranteed to be signed and 32 bits wide.
//
typedef int LONG32, *PLONG32;
typedef int INT32, *PINT32;
//
// The following types are guaranteed to be unsigned and 32 bits wide.
//
typedef unsigned int ULONG32, *PULONG32;
typedef unsigned int DWORD32, *PDWORD32;
typedef unsigned int UINT32, *PUINT32;
//
// The INT_PTR is guaranteed to be the same size as a pointer. Its
// size with change with pointer size (32/64). It should be used
// anywhere that a pointer is cast to an integer type. UINT_PTR is
// the unsigned variation.
//
// HALF_PTR is half the size of a pointer it intended for use with
// within strcuture which contain a pointer and two small fields.
// UHALF_PTR is the unsigned variation.
//
#ifdef _WIN64
typedef __int64 INT_PTR, *PINT_PTR;
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
#define MAXINT_PTR (0x7fffffffffffffffI64)
#define MININT_PTR (0x8000000000000000I64)
#define MAXUINT_PTR (0xffffffffffffffffUI64)
typedef unsigned int UHALF_PTR, *PUHALF_PTR;
typedef int HALF_PTR, *PHALF_PTR;
#define MAXUHALF_PTR (0xffffffffUL)
#define MAXHALF_PTR (0x7fffffffL)
#define MINHALF_PTR (0x80000000L)
#pragma warning(disable:4311) // type cast truncation
#if !defined(__midl)
__inline
unsigned long
HandleToUlong(
void *h
)
{
return((unsigned long) h );
}
__inline
unsigned long
PtrToUlong(
void *p
)
{
return((unsigned long) p );
}
__inline
unsigned short
PtrToUshort(
void *p
)
{
return((unsigned short) p );
}
__inline
long
PtrToLong(
void *p
)
{
return((long) p );
}
__inline
short
PtrToShort(
void *p
)
{
return((short) p );
}
#endif
#pragma warning(3:4311) // type cast truncation
#else
typedef long INT_PTR, *PINT_PTR;
typedef unsigned long UINT_PTR, *PUINT_PTR;
#define MAXINT_PTR (0x7fffffffL)
#define MININT_PTR (0x80000000L)
#define MAXUINT_PTR (0xffffffffUL)
typedef unsigned short UHALF_PTR, *PUHALF_PTR;
typedef short HALF_PTR, *PHALF_PTR;
#define MAXUHALF_PTR 0xffff
#define MAXHALF_PTR 0x7fff
#define MINHALF_PTR 0x8000
#define HandleToUlong( h ) ((ULONG) (h) )
#define PtrToUlong( p ) ((ULONG) (p) )
#define PtrToLong( p ) ((LONG) (p) )
#define PtrToUshort( p ) ((unsigned short) (p) )
#define PtrToShort( p ) ((short) (p) )
#endif
//
// SIZE_T used for counts or ranges which need to span the range of
// of a pointer. SSIZE_T is the signed variation.
//
typedef UINT_PTR SIZE_T, *PSIZE_T;
typedef INT_PTR SSIZE_T, *PSSIZE_T;
//
// The following types are guaranteed to be signed and 64 bits wide.
//
typedef __int64 LONG64, *PLONG64;
typedef __int64 INT64, *PINT64;
//
// The following types are guaranteed to be unsigned and 64 bits wide.
//
typedef unsigned __int64 ULONG64, *PULONG64;
typedef unsigned __int64 DWORD64, *PDWORD64;
typedef unsigned __int64 UINT64, *PUINT64;
#ifdef __cplusplus
}
#endif
#endif // _BASETSD_H_
2. resource.hm
// Microsoft Developer Studio generated Help ID include file.
// Used by ScientificCalculator.rc
//
#define HIDC_EDIT_DISPLAY 0x806603f2 // IDD_SCIENTIFICCALCULATOR_DIALOG
[English (U.S.)]