-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
96 lines (68 loc) · 2.29 KB
/
Copy pathmain.cpp
File metadata and controls
96 lines (68 loc) · 2.29 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "parser.h"
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static HWND hEdit;
static HWND hText;
switch (uMsg) {
case WM_CREATE: {
VerticalLayout layout{ 20, 15, 20 };
hText = CreateWindowEx(
0, L"STATIC", L"Result",
WS_CHILD | WS_VISIBLE,
layout.marginX, layout.Append(layout.height), 300, layout.height,
hwnd, (HMENU)101, GetModuleHandle(nullptr), nullptr
);
hEdit = CreateWindowEx(
0, L"EDIT", L"",
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
layout.marginX, layout.Append(layout.height), 300, layout.height,
hwnd, (HMENU)ID::ID_EDIT_BOX, NULL, NULL
);
CreateWindowEx(
0, L"BUTTON", L"=",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
layout.marginX, layout.Append(layout.height), 120, layout.height,
hwnd, (HMENU)ID::ID_BUTTON, NULL, NULL
);
return 0;
}
case WM_COMMAND:
if (LOWORD(wParam) == (WPARAM)ID::ID_BUTTON && HIWORD(wParam) == BN_CLICKED) {
std::wstring buf;
buf.resize(512);
int len = GetWindowText(hEdit, &buf[0], (int)buf.size());
buf.resize(len);
Parser expr1{ buf,hText };
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nShowCmd) {
const wchar_t* CLASS_NAME = L"WindowClass";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0,
CLASS_NAME,
L"Test",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, hInstance, NULL
);
if (!hwnd) {
return 0;
}
ShowWindow(hwnd, nShowCmd);
MSG msg = { };
while (GetMessageA(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
return 0;
}