-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.cpp
More file actions
32 lines (29 loc) · 959 Bytes
/
Copy pathfunctions.cpp
File metadata and controls
32 lines (29 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include"functions.h"
void calculate(HWND handle) {
WCHAR input_field1[100]{}, input_field2[100]{}, _operator[5]{}, buffer[100]{};
int result{};
GetWindowTextW(input1, input_field1, 100);
GetWindowTextW(input2, input_field2, 100);
GetWindowTextW(op_symb, _operator, 5);
if (wcscmp(input_field1, L"") != 0 && wcscmp(input_field2, L"") != 0 && wcscmp(_operator, L"") != 0) {
if (wcscmp(_operator, L"+") == 0) {
result = _wtoi(input_field1) + _wtoi(input_field2);
}
if (wcscmp(_operator, L"-") == 0) {
result = _wtoi(input_field1) - _wtoi(input_field2);
}
if (wcscmp(_operator, L"X") == 0) {
result = _wtoi(input_field1) * _wtoi(input_field2);
}
if (wcscmp(_operator, L"/") == 0) {
if (_wtoi(input_field2) != 0) {
result = _wtoi(input_field1) / _wtoi(input_field2);
}
else {
MessageBox(handle, L"Divide By zero", L"Error", MB_OK);
}
}
}
wsprintf(buffer, L"%d", result);
SetWindowTextW(textView, buffer);
}