-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathPythonApplicationProcedure.cpp
More file actions
358 lines (300 loc) · 7.75 KB
/
Copy pathPythonApplicationProcedure.cpp
File metadata and controls
358 lines (300 loc) · 7.75 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
#include "StdAfx.h"
#include "PythonApplication.h"
#include "Eterlib/Camera.h"
#include <winuser.h>
static int gs_nMouseCaptureRef = 0;
void CPythonApplication::SafeSetCapture()
{
SetCapture(m_hWnd);
gs_nMouseCaptureRef++;
}
void CPythonApplication::SafeReleaseCapture()
{
gs_nMouseCaptureRef--;
if (gs_nMouseCaptureRef==0)
ReleaseCapture();
}
void CPythonApplication::__SetFullScreenWindow(HWND hWnd, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP)
{
DEVMODE DevMode;
DevMode.dmSize = sizeof(DevMode);
DevMode.dmBitsPerPel = dwBPP;
DevMode.dmPelsWidth = dwWidth;
DevMode.dmPelsHeight = dwHeight;
DevMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
LONG Error = ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN);
if(Error == DISP_CHANGE_RESTART)
{
ChangeDisplaySettings(0,0);
}
}
void CPythonApplication::__MinimizeFullScreenWindow(HWND hWnd, DWORD dwWidth, DWORD dwHeight)
{
ChangeDisplaySettings(0, 0);
SetWindowPos(hWnd, 0, 0, 0,
dwWidth,
dwHeight,
SWP_SHOWWINDOW);
ShowWindow(hWnd, SW_MINIMIZE);
}
LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
const int c_DoubleClickTime = 300;
const int c_DoubleClickBox = 5;
static int s_xDownPosition = 0;
static int s_yDownPosition = 0;
switch (uiMsg)
{
case WM_ACTIVATEAPP:
{
m_isActivateWnd = (wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE);
if (m_isActivateWnd)
{
m_SoundEngine.RestoreVolume();
//////////////////
if (m_isWindowFullScreenEnable)
{
__SetFullScreenWindow(hWnd, m_dwWidth, m_dwHeight, m_pySystem.GetBPP());
}
}
else
{
m_SoundEngine.SaveVolume(m_isMinimizedWnd);
//////////////////
if (m_isWindowFullScreenEnable)
{
__MinimizeFullScreenWindow(hWnd, m_dwWidth, m_dwHeight);
}
if (IsUserMovingMainWindow())
{
SetUserMovingMainWindow(false);
}
}
}
break;
case WM_INPUTLANGCHANGE:
return CPythonIME::Instance().WMInputLanguage(hWnd, uiMsg, wParam, lParam);
break;
case WM_IME_STARTCOMPOSITION:
return CPythonIME::Instance().WMStartComposition(hWnd, uiMsg, wParam, lParam);
break;
case WM_IME_COMPOSITION:
return CPythonIME::Instance().WMComposition(hWnd, uiMsg, wParam, lParam);
break;
case WM_IME_ENDCOMPOSITION:
return CPythonIME::Instance().WMEndComposition(hWnd, uiMsg, wParam, lParam);
break;
case WM_IME_NOTIFY:
return CPythonIME::Instance().WMNotify(hWnd, uiMsg, wParam, lParam);
break;
case WM_IME_SETCONTEXT:
lParam &= ~(ISC_SHOWUICOMPOSITIONWINDOW | ISC_SHOWUIALLCANDIDATEWINDOW);
break;
case WM_CHAR:
return CPythonIME::Instance().WMChar(hWnd, uiMsg, wParam, lParam);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE && IsUserMovingMainWindow())
SetUserMovingMainWindow(false);
OnIMEKeyDown(LOWORD(wParam));
break;
case WM_LBUTTONDOWN:
SafeSetCapture();
if (ELTimer_GetMSec() - m_dwLButtonDownTime < c_DoubleClickTime &&
abs(LOWORD(lParam) - s_xDownPosition) < c_DoubleClickBox &&
abs(HIWORD(lParam) - s_yDownPosition) < c_DoubleClickBox)
{
m_dwLButtonDownTime = 0;
OnMouseLeftButtonDoubleClick(short(LOWORD(lParam)), short(HIWORD(lParam)));
}
else
{
m_dwLButtonDownTime = ELTimer_GetMSec();
OnMouseLeftButtonDown(short(LOWORD(lParam)), short(HIWORD(lParam)));
}
s_xDownPosition = LOWORD(lParam);
s_yDownPosition = HIWORD(lParam);
if (IsUserMovingMainWindow())
SetUserMovingMainWindow(false);
return 0;
case WM_LBUTTONUP:
m_dwLButtonUpTime = ELTimer_GetMSec();
if (hWnd == GetCapture())
{
SafeReleaseCapture();
OnMouseLeftButtonUp(short(LOWORD(lParam)), short(HIWORD(lParam)));
}
return 0;
case WM_MBUTTONDOWN:
SafeSetCapture();
UI::CWindowManager::Instance().RunMouseMiddleButtonDown(short(LOWORD(lParam)), short(HIWORD(lParam)));
// OnMouseMiddleButtonDown(short(LOWORD(lParam)), short(HIWORD(lParam)));
break;
case WM_MBUTTONUP:
if (GetCapture() == hWnd)
{
SafeReleaseCapture();
UI::CWindowManager::Instance().RunMouseMiddleButtonUp(short(LOWORD(lParam)), short(HIWORD(lParam)));
// OnMouseMiddleButtonUp(short(LOWORD(lParam)), short(HIWORD(lParam)));
}
break;
case WM_RBUTTONDOWN:
SafeSetCapture();
OnMouseRightButtonDown(short(LOWORD(lParam)), short(HIWORD(lParam)));
return 0;
case WM_RBUTTONUP:
if (hWnd == GetCapture())
{
SafeReleaseCapture();
OnMouseRightButtonUp(short(LOWORD(lParam)), short(HIWORD(lParam)));
}
return 0;
case 0x20a:
if (CPythonApplication::Instance().IsWebPageMode())
{
// 웹브라우저 상태일때는 휠 작동 안되도록 처리
}
else
{
OnMouseWheel(short(HIWORD(wParam)));
}
break;
case WM_SIZE:
switch (wParam)
{
case SIZE_RESTORED:
case SIZE_MAXIMIZED:
{
RECT rcWnd;
GetClientRect(&rcWnd);
UINT uWidth=rcWnd.right-rcWnd.left;
UINT uHeight=rcWnd.bottom-rcWnd.left;
m_grpDevice.ResizeBackBuffer(uWidth, uHeight);
}
break;
}
if (wParam==SIZE_MINIMIZED)
m_isMinimizedWnd=true;
else
m_isMinimizedWnd=false;
OnSizeChange(short(LOWORD(lParam)), short(HIWORD(lParam)));
break;
case WM_EXITSIZEMOVE:
{
RECT rcWnd;
GetClientRect(&rcWnd);
#ifdef ENABLE_WINDOW_RESIZE
m_isResizing = false;
UINT uWidth = rcWnd.right - rcWnd.left;
UINT uHeight = rcWnd.bottom - rcWnd.top;
m_grpDevice.ResizeBackBuffer(uWidth, uHeight);
OnSizeChange(uWidth, uHeight);
#else
UINT uWidth=rcWnd.right-rcWnd.left;
UINT uHeight=rcWnd.bottom-rcWnd.left;
m_grpDevice.ResizeBackBuffer(uWidth, uHeight);
OnSizeChange(short(LOWORD(lParam)), short(HIWORD(lParam)));
#endif
}
break;
case WM_NCLBUTTONDOWN:
{
switch (wParam)
{
case HTMAXBUTTON:
ShowWindow(hWnd, IsZoomed(hWnd) ? SW_RESTORE : SW_MAXIMIZE);
return 0;
case HTSYSMENU:
return 0;
case HTMINBUTTON:
ShowWindow(hWnd, SW_MINIMIZE);
return 0;
case HTCLOSE:
RunPressExitKey();
return 0;
case HTCAPTION:
if (!IsUserMovingMainWindow())
SetUserMovingMainWindow(true);
return 0;
}
break;
}
case WM_NCLBUTTONUP:
{
if (IsUserMovingMainWindow())
SetUserMovingMainWindow(false);
break;
}
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
case WM_CONTEXTMENU:
return 0;
case WM_SYSCOMMAND:
if (wParam == SC_KEYMENU)
return 0;
break;
#ifdef ENABLE_WINDOW_RESIZE
case WM_ENTERSIZEMOVE:
m_isResizing = true;
break;
case WM_GETMINMAXINFO:
{
MINMAXINFO* pMMI = (MINMAXINFO*)lParam;
RECT rcMinClient = { 0, 0, 800, 600 };
AdjustWindowRectEx(&rcMinClient, GetWindowStyle(m_hWnd), GetMenu(m_hWnd) != NULL, GetWindowExStyle(m_hWnd));
pMMI->ptMinTrackSize.x = rcMinClient.right - rcMinClient.left;
pMMI->ptMinTrackSize.y = rcMinClient.bottom - rcMinClient.top;
break;
}
#endif
case WM_SYSKEYDOWN:
switch (LOWORD(wParam))
{
case VK_F10:
break;
}
break;
case WM_SYSKEYUP:
switch(LOWORD(wParam))
{
case 18:
return FALSE;
break;
case VK_F10:
break;
}
break;
case WM_SETCURSOR:
#ifdef ENABLE_WINDOW_RESIZE
if (LOWORD(lParam) == HTCLIENT && IsActive())
#else
if (IsActive())
#endif
{
if (m_bCursorVisible && CURSOR_MODE_HARDWARE == m_iCursorMode)
{
SetCursor((HCURSOR) m_hCurrentCursor);
return 0;
}
else
{
SetCursor(NULL);
return 0;
}
}
break;
case WM_CLOSE:
#ifdef _DEBUG
PostQuitMessage(0);
#else
RunPressExitKey();
#endif
return 0;
case WM_DESTROY:
return 0;
default:
//Tracenf("%x msg %x", timeGetTime(), uiMsg);
break;
}
return CMSApplication::WindowProcedure(hWnd, uiMsg, wParam, lParam);
}