-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
440 lines (306 loc) · 9.04 KB
/
Copy pathMain.cpp
File metadata and controls
440 lines (306 loc) · 9.04 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
// Vision Explorer
// v0.01
// pipmix.com
#include "Headers.h"
#include "Tools.h"
#include "Console.h"
#include "Button.h"
ATOM RegisterWindowClass(HINSTANCE hInstance);
BOOL CreateInstance(HINSTANCE, int);
bool windowHasFocus = false;
static TCHAR szWindowClass[] = _T("MapEditWndClass");
static TCHAR szTitle[] = _T("Vision");
int gWidth = 768;
int gHeight = 768;
HINSTANCE hInst;
HWND hMainWindow;
HWND hTest;
HWND hText;
HWND hSidePanel;
HWND hTablePanel;
HWND hConsolePanel;
HFONT hFont1;
HWND hButPlay;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildProc(HWND, UINT, WPARAM, LPARAM);
void CommandMsg(HWND hWnd, WPARAM wParam);
void RegisterChild1();
void RegisterChild2();
void GetDir();
//test var
int v_panelWidth = 200;
int v_panelHeight = 600;
int v_maxW = 0;
int v_maxH = 0;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
RegisterWindowClass(hInstance);
CreateInstance(hInstance, nCmdShow);
INITCOMMONCONTROLSEX icc = { sizeof(INITCOMMONCONTROLSEX),
ICC_BAR_CLASSES | ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_STANDARD_CLASSES |
ICC_TREEVIEW_CLASSES | ICC_USEREX_CLASSES | ICC_WIN95_CLASSES };
InitCommonControlsEx(&icc);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
ATOM RegisterWindowClass(HINSTANCE hInstance) {
WNDCLASSEX wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = (HICON)LoadImage(NULL, "largeicon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = GetSysColorBrush(COLOR_GRAYTEXT);// (HBRUSH)(COLOR_GRAYTEXT);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = (HICON)LoadImage(NULL, "smallicon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
return RegisterClassEx(&wcex);
}
BOOL CreateInstance(HINSTANCE hInstance, int nCmdShow) {
hInst = hInstance;
//HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | SS_OWNERDRAW | WS_EX_TOPMOST,
// CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
hMainWindow = CreateWindowEx(
0,
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, gWidth, gWidth,
NULL, NULL, hInstance, NULL);
ShowWindow(hMainWindow, nCmdShow);
UpdateWindow(hMainWindow);
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
UINT check;
HMENU hTmp = GetMenu(hWnd);
const int BUF_LEN = 10;
wchar_t buf[BUF_LEN];
RECT clientRect;
GetWindowRect(hWnd, &clientRect);
RECT windowRect;
GetWindowRect(hWnd, &windowRect);
switch (message) {
case WM_CREATE:
RegisterHotKey(hWnd, IDHK_CENTER, MOD_CONTROL, 0x43);
CenterWindow(hWnd);
AddMenus(hWnd);
AddTextBox(hWnd);
hTest = CreateWindowExW(0, STATUSCLASSNAMEW, NULL,
WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd,
(HMENU)1, GetModuleHandle(NULL), NULL);
/*
RegisterChild1();
CreateWindowW(L"RedPanelClass", NULL,
WS_CHILD | WS_VISIBLE,
20, 20, 80, 80,
hWnd, (HMENU)1, NULL, NULL);
RegisterChild2();
CreateWindowEx(0,
"EChild2Class", NULL,
WS_CHILD | WS_VISIBLE,
100, 100, 280, 280,
hWnd, (HMENU)2, GetModuleHandle(NULL), NULL);
CreateWindowW(L"static", L"x: Test ",
WS_CHILD | WS_VISIBLE,
10, 60, 100, 20,
hWnd, 0, NULL, NULL);
hText = CreateWindowW(L"static", L"0",
WS_CHILD | WS_VISIBLE,
60, 60, 100, 20,
hWnd, 0, NULL, NULL);
*/
hSidePanel = CreateSidePanel(hWnd);
hTablePanel = CreateTablePanel(hWnd);
hConsolePanel = CreateConsole(hWnd);
ShowWindow(hTest, SW_HIDE);
hButPlay = CreateButton(hConsolePanel);
//SendMessage(hConsolePanel, WM_SETFONT, (WPARAM)consoleFont, (LPARAM)MAKELONG(TRUE, 0));
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
hFont1 = CreateFontIndirect(&ncm.lfMessageFont);
SendMessage(hConsolePanel, WM_SETFONT, (WPARAM)hFont1, 0);
SendMessage(hButPlay, WM_SETFONT, (WPARAM)hFont1, 0);
break;
return 0;
case BN_CLICKED:
if (hButPlay == (HWND)lParam)MessageBeep(MB_ICONINFORMATION);
break;
case WM_MOVE:
StringCbPrintfW(buf, BUF_LEN, L"%ld", clientRect.left);
SetWindowTextW(hText, buf);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE) {
int tmp = MessageBoxW(hWnd, L"Quit?", L"Message", MB_OKCANCEL);
if (tmp == IDOK) SendMessage(hWnd, WM_CLOSE, 0, 0);
}
break;
case WM_KILLFOCUS:
windowHasFocus = 0;
break;
case WM_SETFOCUS:
windowHasFocus = 1;
break;
case WM_COMMAND:
CommandMsg(hWnd, wParam);
break;
case WM_HOTKEY: {
//HWND temp = GetActiveWindow();
HWND temp = GetForegroundWindow();
if (temp != hWnd)break;
}
if ((wParam) == IDHK_CENTER) {
CenterWindow(hWnd);
}
break;
case WM_SIZE:
SendMessage(hTest, WM_SIZE, wParam, lParam);
MoveWindow(hSidePanel, 0, 0, v_panelWidth, v_panelHeight, 1);
MoveWindow(hTablePanel, v_panelWidth, 0, clientRect.right, v_panelHeight, 1);
MoveWindow(hConsolePanel, 0, v_panelHeight, clientRect.right, clientRect.bottom, 1);
break;
case WM_RBUTTONUP:
RightClickMenu(hWnd, lParam);
break;
case WM_LBUTTONUP:
ReleaseCapture();
break;
case WM_LBUTTONDOWN:
SetCapture(hWnd);
break;
case WM_DESTROY:
UnregisterHotKey(hWnd, IDHK_CENTER);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
void CommandMsg(HWND hWnd, WPARAM wParam) {
switch (LOWORD(wParam)) {
case DEF_BUT_PLAY:
MessageBeep(MB_ICONINFORMATION);
break;
case IDM_FILE_NEW:
ShowWindow(hTest, SW_HIDE);
break;
case IDM_FILE_OPEN:
ShowWindow(hTest, SW_SHOW);
MessageBeep(MB_ICONINFORMATION);
break;
case IDM_FILE_EXIT:
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
case IDM_EDIT_COPY: {
int x = GetSystemMetrics(SM_CXSCREEN);
int y = GetSystemMetrics(SM_CYSCREEN);
MessageBoxW(NULL, IntToLPCWSTR(x), IntToLPCWSTR(y), MB_OK);
}
break;
case IDM_SETTINGS_ONE:{
CenterWindow(hWnd);
RECT rc = { 0 };
GetWindowRect(hWnd, &rc);
int win_w = rc.right - rc.left;
int win_h = rc.bottom - rc.top;
MessageBoxW(NULL, IntToLPCWSTR(win_h), IntToLPCWSTR(win_w), MB_OK);
}
break;
case IDM_EDIT_ONTOP:
if (FlipCheckMenu(hWnd, IDM_EDIT_ONTOP))
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
else
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
// current pos, current size
break;
case IDM_EDIT_PASTE:
FlipCheckMenu(hWnd, IDM_EDIT_PASTE);
break;
case IDM_WINDOW_WIREFRAME:
SetRadioMenu(hWnd, IDM_WINDOW_WIREFRAME, IDM_WINDOW_TEXTURED, IDM_WINDOW_WIREFRAME);
break;
case IDM_WINDOW_SHADED:
SetRadioMenu(hWnd, IDM_WINDOW_WIREFRAME, IDM_WINDOW_TEXTURED, IDM_WINDOW_SHADED);
break;
case IDM_WINDOW_TEXTURED:
SetRadioMenu(hWnd, IDM_WINDOW_WIREFRAME, IDM_WINDOW_TEXTURED, IDM_WINDOW_TEXTURED);
break;
}
}
LRESULT CALLBACK ChildProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_LBUTTONUP:
MessageBeep(MB_OK);
CenterWindow(hWnd);
break;
}
return DefWindowProcW(hWnd, message, wParam, lParam);
}
void RegisterChild1() {
HBRUSH hbrush = CreateSolidBrush(RGB(0, 0, 255));
WNDCLASSW rwc = { 0 };
rwc.lpszClassName = L"RedPanelClass";
rwc.hbrBackground = hbrush;
rwc.lpfnWndProc = ChildProc;
rwc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassW(&rwc);
}
void RegisterChild2() {
WNDCLASSEX wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.lpszClassName = "EChild2Class";
wcex.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(55, 55, 55));;
wcex.lpfnWndProc = ChildProc;
wcex.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassEx(&wcex);
}
void GetDir() {
CHAR fileName[FILENAME_MAX];
WIN32_FIND_DATA findData = { 0 };
HANDLE hFind = ::FindFirstFile("c:/files/aab/Levels/", &findData);
//HANDLE handle = FindFirstFile(fileName, &findData);
while (hFind != INVALID_HANDLE_VALUE){
findData.cFileName;
if (FindNextFile(hFind, &findData) == FALSE)
break;
}
FindClose(hFind);
/*
wchar_t sp[128];
wsprintf(sp, L"%s/*.*", folder.c_str());
WIN32_FIND_DATA fd;
HANDLE hFind = ::FindFirstFile(sp, &fd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
// read all (real) files in current folder
// , delete '!' read other 2 default folder . and ..
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
names.push_back(fd.cFileName);
}
else //Put folders into vector
{
folders.push_back(fd.cFileName);
}
} while (::FindNextFile(hFind, &fd));
::FindClose(hFind);
}
if (!slim) {
for (int i = 0; i < names.size(); i++) {
wcout << names[i] << endl;
}
for (int i = 0; i < folders.size(); i++) {
//wcout << folders[i] << endl;
}
}
*/
}