マウスカーソルへIMEモードの表示
Révision | 26bbcab399b63f3129c38ae3752f559fa1326b93 (tree) |
---|---|
l'heure | 2023-07-05 13:20:41 |
Auteur | JeffyTS <jeffyts@outl...> |
Commiter | JeffyTS |
1.1.1.7
@@ -1,9 +1,10 @@ | ||
1 | -// CommonDef.h | |
1 | +// | |
2 | +// CommonDef.h | |
2 | 3 | // Copyright (C) 1993 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0001 2023/04/27 JeffyTS New edit | |
7 | +// #0000 2023/04/27 JeffyTS New edit | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -17,8 +18,18 @@ | ||
17 | 18 | // |
18 | 19 | #define MAX_LOADSTRING 100 |
19 | 20 | |
21 | +// Files | |
22 | +#define FULL_FLUSHMOUSE_EXE L"%ProgramFiles%\\JeffyTS\\FlushMouse\\FlushMouse.exe" | |
23 | +#define FULL_FLUSHMOUSE32_EXE L"%ProgramFiles%\\JeffyTS\\FlushMouse\\FlushMouse32.exe" | |
24 | +#define FULL_FLUSHMOUSE_DLL L"%ProgramFiles%\\JeffyTS\\FlushMouse\\FlushMouseDLL.dll" | |
25 | +#define FULL_FLUSHMOUSE32_DLL L"%ProgramFiles%\\JeffyTS\\FlushMouse\\FlushMouseDLL32.dll" | |
26 | +#define FLUSHMOUSE_EXE L"FlushMouse.exe" | |
27 | +#define FLUSHMOUSE32_EXE L"FlushMouse32.exe" | |
28 | +#define FLUSHMOUSE_DLL L"FlushMouseDLL.dll" | |
29 | +#define FLUSHMOUSE32_DLL L"FlushMouseDLL32.dll" | |
30 | + | |
20 | 31 | // Window Class |
21 | -#define CLASS_FLUSHMOUSE L"FlushMouse-{E598B54C-A36A-4CDF-BC77-7082CEEDAA46}" | |
32 | +#define CLASS_FLUSHMOUSE L"FlushMouse-{E598B54C-A36A-4CDF-BC77-7082CEEDAA46}" | |
22 | 33 | #define CLASS_FLUSHMOUSE32 L"FlushMouse32-{E598B54C-A36A-4CDF-BC77-7082CEEDAA46}" |
23 | 34 | |
24 | 35 | // for IME |
@@ -1,9 +1,10 @@ | ||
1 | -// Cursor.cpp | |
1 | +// | |
2 | +// Cursor.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/03 JeffyTS New edit. | |
7 | +// #0000 2022/03/03 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // Include |
@@ -12,16 +13,20 @@ | ||
12 | 13 | #include "pch.h" |
13 | 14 | #include "Profile.h" |
14 | 15 | #include "Cursor.h" |
15 | -#include "CommonDef.h" | |
16 | 16 | #include "FlushMouseLIB.h" |
17 | +#include "CommonDef.h" | |
17 | 18 | #include "..\FlushMouseDLL\EventlogDll.h" |
18 | 19 | #include "..\MiscLIB\CRegistry.h" |
19 | 20 | |
20 | 21 | // |
22 | +// Library | |
23 | +// | |
24 | + | |
25 | +// | |
21 | 26 | // Define |
22 | 27 | // |
23 | -#define FLUSHMOUSECURSORDIR _T("\\JeffyTS\\FlushMouse\\") | |
24 | -#define FLUSHMOUSECURSORDAT _T("FlushMouseCursor.dat") | |
28 | +#define FLUSHMOUSECURSORDIR _T("\\JeffyTS\\FlushMouse\\") | |
29 | +#define FLUSHMOUSECURSORDAT _T("FlushMouseCursor.dat") | |
25 | 30 | |
26 | 31 | // IME Cursor Change Thread |
27 | 32 | #define IMECURSORCHANGETHREADID 1 |
@@ -45,412 +50,12 @@ | ||
45 | 50 | // |
46 | 51 | |
47 | 52 | // |
48 | -// Class CIME | |
49 | -// | |
50 | -CIME::CIME() | |
51 | -{ | |
52 | - lpstVirtualDesktop = new VIRTUALDESKTOP[sizeof(VIRTUALDESKTOP)]; | |
53 | - ZeroMemory(lpstVirtualDesktop, sizeof(VIRTUALDESKTOP)); | |
54 | - bGetVirtualDesktopSize(); | |
55 | -} | |
56 | -CIME::~CIME() | |
57 | -{ | |
58 | - if (lpstVirtualDesktop != NULL) delete[] lpstVirtualDesktop; | |
59 | - lpstVirtualDesktop = NULL; | |
60 | -} | |
61 | - | |
62 | -// | |
63 | -// bIsIMEOpen() | |
64 | -// | |
65 | -BOOL CIME::bIsIMEOpen(HWND hWndObserved) | |
66 | -{ | |
67 | - HWND hIMWnd = NULL; | |
68 | - if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
69 | - if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETOPENSTATUS, (LPARAM)NULL) != 0) { | |
70 | - return TRUE; // IME Open | |
71 | - } | |
72 | - } | |
73 | - return FALSE; // IME Close | |
74 | -} | |
75 | - | |
76 | -// | |
77 | -// vIMEOpenCloseForced() | |
78 | -// | |
79 | -VOID CIME::vIMEOpenCloseForced(HWND hWndObserved, DWORD dwIMEOpenClose) | |
80 | -{ | |
81 | - if (hWndObserved == NULL) return; | |
82 | - LPARAM lParam = (LPARAM)dwIMEOpenClose; | |
83 | - EnumChildWindows(hWndObserved, &bEnumChildProcIMEOpenClose, lParam); | |
84 | - return; | |
85 | -} | |
86 | - | |
87 | -// | |
88 | -// vIMEConvertModeChangeForced() | |
89 | -// | |
90 | -VOID CIME::vIMEConvertModeChangeForced(HWND hWndObserved, DWORD dwConvertMode) | |
91 | -{ | |
92 | - if (hWndObserved == NULL) return; | |
93 | - LPARAM lParam = (LPARAM)dwConvertMode; | |
94 | - EnumChildWindows(hWndObserved, &bEnumChildProcIMEConvertMode, lParam); | |
95 | - return; | |
96 | -} | |
97 | - | |
98 | -// | |
99 | -// bEnumChildProcIMEConvertMode() | |
100 | -// | |
101 | -BOOL CALLBACK CIME::bEnumChildProcIMEConvertMode(HWND hWndObserved, LPARAM lParam) | |
102 | -{ | |
103 | - if (hWndObserved == NULL) return FALSE; | |
104 | - HWND hIMWnd = NULL; | |
105 | - if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
106 | - if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETOPENSTATUS, (LPARAM)TRUE) == 0) { | |
107 | - if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETCONVERSIONMODE, (LPARAM)lParam) == 0) { | |
108 | - } | |
109 | - } | |
110 | - } | |
111 | - return TRUE; | |
112 | -} | |
113 | - | |
114 | -// | |
115 | -// bEnumChildProcIMEOpenClose() | |
116 | -// | |
117 | -BOOL CALLBACK CIME::bEnumChildProcIMEOpenClose(HWND hWndObserved, LPARAM lParam) | |
118 | -{ | |
119 | - if (hWndObserved == NULL) return FALSE; | |
120 | - HWND hIMWnd = NULL; | |
121 | - if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
122 | - if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETOPENSTATUS, lParam) == 0) { | |
123 | - } | |
124 | - } | |
125 | - return TRUE; | |
126 | -} | |
127 | - | |
128 | -// | |
129 | -// dwIMEMode() | |
130 | -// | |
131 | -DWORD CIME::dwIMEMode(HWND hWndObserved, BOOL bForceHiragana) | |
132 | -{ | |
133 | - if (hWndObserved != NULL) { | |
134 | - HWND hIMWnd = NULL; | |
135 | - HKL hkl = NULL; | |
136 | - DWORD dwInputLocale = 0; | |
137 | - DWORD dwConvertMode = 0; | |
138 | - if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
139 | - if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETOPENSTATUS, NULL) != 0) { | |
140 | - if ((dwConvertMode = (DWORD)SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETCONVERSIONMODE, NULL)) != 0) { | |
141 | - switch (dwConvertMode) { | |
142 | - case IME_CMODE_NATIVE: | |
143 | - dwConvertMode = IMEOFF; | |
144 | - break; | |
145 | - case ZENHIRA_IMEON: | |
146 | - case (ZENHIRA_IMEON ^ IME_CMODE_ROMAN): | |
147 | - dwConvertMode = ZENHIRA_IMEON; | |
148 | - break; | |
149 | - case HANEISU_IMEON: | |
150 | - case (HANEISU_IMEON ^ IME_CMODE_ROMAN): | |
151 | - dwConvertMode = HANEISU_IMEON; | |
152 | - break; | |
153 | - case HANKANA_IMEON: | |
154 | - case (HANKANA_IMEON ^ IME_CMODE_ROMAN): | |
155 | - dwConvertMode = HANKANA_IMEON; | |
156 | - break; | |
157 | - case ZENEISU_IMEON: | |
158 | - case (ZENEISU_IMEON ^ IME_CMODE_ROMAN): | |
159 | - dwConvertMode = ZENEISU_IMEON; | |
160 | - break; | |
161 | - case ZENKANA_IMEON: | |
162 | - case (ZENKANA_IMEON ^ IME_CMODE_ROMAN): | |
163 | - dwConvertMode = ZENKANA_IMEON; | |
164 | - break; | |
165 | - default: | |
166 | - dwConvertMode = IMEOFF; | |
167 | - } | |
168 | - if ((bForceHiragana != FALSE) && (dwConvertMode != ZENHIRA_IMEON)) { | |
169 | - vIMEConvertModeChangeForced(hWndObserved, ZENHIRA_IMEON); | |
170 | - dwConvertMode = ZENHIRA_IMEON; | |
171 | - return ZENHIRA_IMEON; | |
172 | - } | |
173 | - if ((hkl = Cime->hklGetInputLocale(hWndObserved)) != (HKL)0) { | |
174 | - if ((dwInputLocale = Cime->dwGetInputLocale()) != 0) { | |
175 | - if ((hkl = (HKL)(((UINT64)hkl & KB_MASK) | (dwInputLocale & LANG_MASK))) != JP_IME) { // Not JP IME KB | |
176 | - dwConvertMode = IMEOFF; // IMEOFFとする | |
177 | - } | |
178 | - } | |
179 | - } | |
180 | - return dwConvertMode; | |
181 | - } | |
182 | - } | |
183 | - } | |
184 | - } | |
185 | - return IMEOFF; | |
186 | -} | |
187 | - | |
188 | -// | |
189 | -// vActivateIME() | |
190 | -// | |
191 | -VOID CIME::vActivateIME(HWND hWndObserved) | |
192 | -{ | |
193 | - EnumChildWindows(hWndObserved, &bEnumChildProcActivateIME, NULL); | |
194 | -} | |
195 | - | |
196 | -// | |
197 | -// bEnumChildProcActivateIME() | |
198 | -// | |
199 | -BOOL CALLBACK CIME::bEnumChildProcActivateIME(HWND hWnd, LPARAM lParam) | |
200 | -{ | |
201 | - UNREFERENCED_PARAMETER(lParam); | |
202 | - | |
203 | - HWND hIMWnd = ImmGetDefaultIMEWnd(hWnd); | |
204 | - if (hIMWnd != NULL) { | |
205 | - SendMessage(hIMWnd, WM_ACTIVATE, (WPARAM)WA_ACTIVE, (LPARAM)NULL); | |
206 | - LPTSTR lpszBuffer = new TCHAR[_MAX_PATH]; | |
207 | - ZeroMemory(lpszBuffer, (sizeof(TCHAR) * _MAX_PATH)); | |
208 | - if (GetClassName(hIMWnd, lpszBuffer, _MAX_PATH) != 0) { | |
209 | - HWND hIMEWnd = FindWindow(lpszBuffer, NULL); | |
210 | - if (hIMEWnd != NULL) { | |
211 | - SendMessage(hIMEWnd, WM_ACTIVATE, (WPARAM)WA_ACTIVE, (LPARAM)NULL); | |
212 | - if (lpszBuffer != NULL) delete[] lpszBuffer; | |
213 | - return TRUE; | |
214 | - } | |
215 | - } | |
216 | - if (lpszBuffer != NULL) delete[] lpszBuffer; | |
217 | - } | |
218 | - return TRUE; | |
219 | -} | |
220 | - | |
221 | -// | |
222 | -// bMoveIMEToolbar() | |
223 | -// | |
224 | -BOOL CIME::bMoveIMEToolbar() | |
225 | -{ | |
226 | - if (bExistIMEToolbar()) { | |
227 | - while ((GetAsyncKeyState(VK_MENU) & 0x8000) || (GetAsyncKeyState(VK_CONTROL) & 0x8000)) { | |
228 | - Sleep(50); | |
229 | - } | |
230 | - HWND hIMEWnd = FindWindow(_T("ApplicationFrameWindow"), NULL); | |
231 | - if (hIMEWnd != NULL) { | |
232 | - POINT ptCursor{}; | |
233 | - if (GetCursorPos(&ptCursor)) { | |
234 | - RECT rc{}; | |
235 | - if (GetWindowRect(hIMEWnd, &rc)) { | |
236 | - HMONITOR hMonitor = NULL; | |
237 | - if ((hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTONEAREST)) != NULL) { | |
238 | - UINT dpiCursorX = 0, dpiCursorY = 0; | |
239 | - if ((GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiCursorX, &dpiCursorY)) == S_OK) { | |
240 | - if ((hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTONEAREST)) != NULL) { | |
241 | - UINT dpiToolbarX = 0, dpiToolbarY = 0; | |
242 | - if ((GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiToolbarX, &dpiToolbarY)) == S_OK) { | |
243 | - // Drawも直す必要あり | |
244 | - LONG CursorMarginX = 0, CursorMarginY = 0; | |
245 | - if ((rc.right - rc.left) > (rc.bottom - rc.top)) { | |
246 | - CursorMarginX = 10 * ((dpiCursorX + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
247 | - CursorMarginY = 16 * ((dpiCursorY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
248 | - } | |
249 | - else { | |
250 | - CursorMarginX = 16 * ((dpiCursorX + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
251 | - CursorMarginY = 10 * ((dpiCursorY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
252 | - } | |
253 | - Sleep(10); | |
254 | - double rcLeft = 0, rcTop = 0; | |
255 | - if ((rc.right - rc.left) > (rc.bottom - rc.top)) { | |
256 | - rcLeft = (LONG)((double)rc.left + (6.0 * ((double)dpiToolbarX + (double)USER_DEFAULT_SCREEN_DPI - 1.0) / (double)USER_DEFAULT_SCREEN_DPI)); | |
257 | - rcTop = (LONG)((double)rc.top + (9.0 * ((double)dpiToolbarX + (double)USER_DEFAULT_SCREEN_DPI - 1.0) / (double)USER_DEFAULT_SCREEN_DPI)); | |
258 | - } | |
259 | - else { | |
260 | - rcLeft = (LONG)((double)rc.left + (9.0 * ((double)dpiToolbarX + (double)USER_DEFAULT_SCREEN_DPI - 1.0) / (double)USER_DEFAULT_SCREEN_DPI)); | |
261 | - rcTop = (LONG)((double)rc.top + (6.0 * ((double)dpiToolbarX + (double)USER_DEFAULT_SCREEN_DPI - 1.0) / (double)USER_DEFAULT_SCREEN_DPI)); | |
262 | - } | |
263 | - double px0 = lpstVirtualDesktop->rcMonitorSize.left; | |
264 | - double py0 = lpstVirtualDesktop->rcMonitorSize.top; | |
265 | - double cx = lpstVirtualDesktop->rcMonitorSize.right - lpstVirtualDesktop->rcMonitorSize.left; | |
266 | - double cy = lpstVirtualDesktop->rcMonitorSize.bottom - lpstVirtualDesktop->rcMonitorSize.top; | |
267 | - LONG xCursor = (LONG)(((((double)ptCursor.x - px0) * 65536.0) + cx - 1.0) / cx); | |
268 | - LONG yCursor = (LONG)(((((double)ptCursor.y - py0) * 65536.0) + cy - 1.0) / cy); | |
269 | - LONG xToolbar = (LONG)(((((double)rcLeft - px0) * 65536.0) + cx - 1.0) / cx); | |
270 | - LONG yToolbar = (LONG)(((((double)rcTop - py0) * 65536.0) + cy - 1.0) / cy); | |
271 | - LPINPUT lpInputs = NULL; | |
272 | - if ((lpInputs = new INPUT[sizeof(INPUT) * 4]) != NULL) { | |
273 | - ZeroMemory(lpInputs, sizeof(INPUT) * 4); | |
274 | - UINT cInputs = (UINT)(0); | |
275 | - // #0 | |
276 | - lpInputs[cInputs].type = INPUT_MOUSE; lpInputs[cInputs].mi.dx = (DWORD)xToolbar; lpInputs[cInputs].mi.dy = (DWORD)yToolbar; | |
277 | - lpInputs[cInputs].mi.mouseData = 0; lpInputs[cInputs].mi.time = 0; lpInputs[cInputs].mi.dwExtraInfo = 0; | |
278 | - lpInputs[cInputs].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK; | |
279 | - ++cInputs; | |
280 | - // #1 | |
281 | - lpInputs[cInputs].type = INPUT_MOUSE; lpInputs[cInputs].mi.dx = (DWORD)xToolbar; lpInputs[cInputs].mi.dy = (DWORD)yToolbar; | |
282 | - lpInputs[cInputs].mi.mouseData = 0; lpInputs[cInputs].mi.time = 0; lpInputs[cInputs].mi.dwExtraInfo = 0; | |
283 | - lpInputs[cInputs].mi.dwFlags = MOUSEEVENTF_LEFTDOWN; | |
284 | - ++cInputs; | |
285 | - // #2 | |
286 | - lpInputs[cInputs].type = INPUT_MOUSE; lpInputs[cInputs].mi.dx = (DWORD)xCursor; lpInputs[cInputs].mi.dy = (DWORD)yCursor; | |
287 | - lpInputs[cInputs].mi.mouseData = 0; lpInputs[cInputs].mi.time = 0; lpInputs[cInputs].mi.dwExtraInfo = 0; | |
288 | - lpInputs[cInputs].mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK; | |
289 | - ++cInputs; | |
290 | - // #3 | |
291 | - lpInputs[cInputs].type = INPUT_MOUSE; lpInputs[cInputs].mi.dx = (DWORD)xCursor; lpInputs[cInputs].mi.dy = (DWORD)yCursor; | |
292 | - lpInputs[cInputs].mi.mouseData = 0; lpInputs[cInputs].mi.time = 0; lpInputs[cInputs].mi.dwExtraInfo = 0; | |
293 | - lpInputs[cInputs].mi.dwFlags = MOUSEEVENTF_LEFTUP; | |
294 | - ++cInputs; | |
295 | - if (SendInput(cInputs, lpInputs, sizeof(INPUT)) == cInputs) { | |
296 | - Sleep(10); | |
297 | - } | |
298 | - delete[] lpInputs; | |
299 | - } | |
300 | - } | |
301 | - } | |
302 | - } | |
303 | - } | |
304 | - } | |
305 | - else { | |
306 | - return FALSE; | |
307 | - } | |
308 | - } | |
309 | - else { | |
310 | - return FALSE; | |
311 | - } | |
312 | - } | |
313 | - else { | |
314 | - return FALSE; | |
315 | - } | |
316 | - } | |
317 | - return TRUE; | |
318 | -} | |
319 | - | |
320 | -// | |
321 | -// bGetVirtualDesktopSize() | |
322 | -// | |
323 | -BOOL CIME::bGetVirtualDesktopSize() | |
324 | -{ | |
325 | - BOOL bRet = FALSE; | |
326 | - if (lpstVirtualDesktop != NULL) { | |
327 | - ZeroMemory(lpstVirtualDesktop, sizeof(VIRTUALDESKTOP)); | |
328 | - if (EnumDisplayMonitors(NULL, NULL, (MONITORENUMPROC)&bGetVirtualDesktopSizeEnumProc, (LPARAM)lpstVirtualDesktop) != 0) { | |
329 | - bRet = TRUE; | |
330 | - } | |
331 | - else { | |
332 | - _Post_equals_last_error_ DWORD err = GetLastError(); | |
333 | - if ((err == ERROR_INVALID_PARAMETER) || (err == ERROR_SUCCESS)) { | |
334 | - bRet = TRUE; | |
335 | - } | |
336 | - else if (err == ERROR_ACCESS_DENIED) { | |
337 | - bRet = TRUE; | |
338 | - } | |
339 | - else { | |
340 | - } | |
341 | - } | |
342 | - } | |
343 | - return bRet; | |
344 | -} | |
345 | - | |
346 | -// | |
347 | -// bGetVirtualDesktopSizeEnumProc() | |
348 | -// | |
349 | -BOOL CIME::bGetVirtualDesktopSizeEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam) | |
350 | -{ | |
351 | - UNREFERENCED_PARAMETER(hDC); | |
352 | - UNREFERENCED_PARAMETER(lprcClip); | |
353 | - LPVIRTUALDESKTOP lpstVirtualDesktop = (LPVIRTUALDESKTOP)lParam; | |
354 | - MONITORINFO stMonInfo{}; stMonInfo.cbSize = sizeof(MONITORINFO); | |
355 | - if (GetMonitorInfo(hMonitor, &stMonInfo) != 0) { | |
356 | - if (stMonInfo.rcMonitor.left <= lpstVirtualDesktop->rcMonitorSize.left) lpstVirtualDesktop->rcMonitorSize.left = stMonInfo.rcMonitor.left; | |
357 | - if (stMonInfo.rcMonitor.right >= lpstVirtualDesktop->rcMonitorSize.right) lpstVirtualDesktop->rcMonitorSize.right = stMonInfo.rcMonitor.right; | |
358 | - if (stMonInfo.rcMonitor.top <= lpstVirtualDesktop->rcMonitorSize.top) lpstVirtualDesktop->rcMonitorSize.top = stMonInfo.rcMonitor.top; | |
359 | - if (stMonInfo.rcMonitor.bottom >= lpstVirtualDesktop->rcMonitorSize.bottom) lpstVirtualDesktop->rcMonitorSize.bottom = stMonInfo.rcMonitor.bottom; | |
360 | - ++lpstVirtualDesktop->iNumOfMonitors; | |
361 | - return TRUE; | |
362 | - } | |
363 | - return FALSE; | |
364 | -} | |
365 | - | |
366 | -// | |
367 | -// bExistIMEToolbar() | |
368 | -// | |
369 | -BOOL CIME::bExistIMEToolbar() | |
370 | -{ | |
371 | -#define SUBKEY _T("Software\\AppDataLow\\software\\Microsoft\\ime\\15.0\\IMEJP\\MSIME") | |
372 | -#define VALUE _T("ToolBarEnabled") | |
373 | - CRegistry* CReg = new CRegistry; | |
374 | - DWORD dwToolBar = 0; | |
375 | - if (!CReg->bReadRegValueDWORD(HKEY_CURRENT_USER, SUBKEY, VALUE, &dwToolBar)) { | |
376 | - } | |
377 | - delete CReg; | |
378 | - if ((bIsNewIME() == TRUE) && (dwToolBar != 0)) return TRUE; | |
379 | - else return FALSE; | |
380 | -#undef SUBKEY | |
381 | -#undef VALUE | |
382 | -} | |
383 | - | |
384 | -// | |
385 | -// bIsNewIME() | |
386 | -// | |
387 | -BOOL CIME::bIsNewIME() | |
388 | -{ | |
389 | -#define SUBKEY _T("Software\\Microsoft\\input\\tsf\\tsf3override\\{03b5835f-f03c-411b-9ce2-aa23e1171e36}") | |
390 | -#define VALUE _T("NoTsf3Override2") | |
391 | - CRegistry* CReg = new CRegistry; | |
392 | - DWORD dwCTF = 0; | |
393 | - if (!CReg->bReadRegValueDWORD(HKEY_CURRENT_USER, SUBKEY, VALUE, &dwCTF)) { | |
394 | - // ERROR_FILE_NOT_FOUND | |
395 | - dwCTF = 0; | |
396 | - } | |
397 | - delete CReg; | |
398 | - if (dwCTF != 0) return FALSE; | |
399 | - else return TRUE; | |
400 | -#undef SUBKEY | |
401 | -#undef VALUE | |
402 | -} | |
403 | - | |
404 | -// | |
405 | -// dGetInputLocale() | |
406 | -// | |
407 | -DWORD CIME::dwGetInputLocale() | |
408 | -{ | |
409 | -#define SUBKEY _T("SOFTWARE\\Microsoft\\Input\\Locales") | |
410 | -#define VALUE _T("InputLocale") | |
411 | - DWORD dwInputLocale = 0; | |
412 | - CRegistry* CReg = new CRegistry; | |
413 | - if (CReg) { | |
414 | - if (!CReg->bReadSystemRegValueDWORD(HKEY_LOCAL_MACHINE, SUBKEY, VALUE, &dwInputLocale)) { | |
415 | - } | |
416 | - delete CReg; | |
417 | - } | |
418 | - return (dwInputLocale & 0x0000ffff); | |
419 | -#undef SUBKEY | |
420 | -#undef VALUE | |
421 | -} | |
422 | - | |
423 | -// | |
424 | -// hklGetInputLocale() | |
425 | -// | |
426 | -HKL CIME::hklGetInputLocale(HWND hWndObserved) | |
427 | -{ | |
428 | - | |
429 | - DWORD dwProcessID = 0; | |
430 | - DWORD dwThreadID = 0; | |
431 | - HKL hkl = NULL; | |
432 | - DWORD dwInputLocale = 0; | |
433 | - if ((dwThreadID = GetWindowThreadProcessId(hWndObserved, &dwProcessID)) != 0) { | |
434 | - if ((hkl = GetKeyboardLayout(dwThreadID)) != NULL) { | |
435 | - int iKeyboardType = GetKeyboardType(1); | |
436 | - if ((iKeyboardType != 2) || (hkl != JP_IME)) hkl = US_ENG; | |
437 | - hkl = (HKL)(((UINT64)hkl & KB_MASK) | (dwInputLocale & LANG_MASK)); | |
438 | - return hkl; | |
439 | - } | |
440 | - } | |
441 | - return (HKL)0; | |
442 | -#undef SUBKEY | |
443 | -#undef VALUE | |
444 | -} | |
445 | - | |
446 | -//S | |
447 | 53 | // class CCursor |
448 | 54 | // |
449 | 55 | CCursor::CCursor() |
450 | 56 | { |
451 | 57 | this->hMainWnd = NULL; |
452 | 58 | |
453 | - // DLL data の初期化 | |
454 | 59 | hModDll = NULL; |
455 | 60 | iCursorDataLoadCount = 0; |
456 | 61 |
@@ -460,6 +65,7 @@ CCursor::CCursor() | ||
460 | 65 | stIMECursorData.bDrawNearCaret = FALSE; |
461 | 66 | stIMECursorData.lpszLoadDatName = NULL; |
462 | 67 | stIMECursorData.lpstFlushMouseCursor = (LPFLUSHMOUSECURSOR)&stFlushMouseCursor; |
68 | + | |
463 | 69 | stIMECursorData.hWnd = NULL; |
464 | 70 | |
465 | 71 | IMECursorChangeThread = NULL; |
@@ -472,27 +78,27 @@ CCursor::CCursor() | ||
472 | 78 | CCursor::~CCursor() |
473 | 79 | { |
474 | 80 | if (DrawIMEModeCaretThread != NULL) { |
475 | - delete DrawIMEModeCaretThread; // Draw IME Mode near by Caret cursor Threadの後始末 | |
81 | + delete DrawIMEModeCaretThread; | |
476 | 82 | DrawIMEModeCaretThread = NULL; |
477 | 83 | } |
478 | 84 | if (CaretWindow != NULL) { |
479 | - delete CaretWindow; // Draw Window near by Caret cursorの削除 | |
85 | + delete CaretWindow; | |
480 | 86 | CaretWindow = NULL; |
481 | 87 | } |
482 | 88 | if (DrawIMEModeThread != NULL) { |
483 | - delete DrawIMEModeThread; // Draw IME Mode near by Mouse cursor Threadの後始末 | |
89 | + delete DrawIMEModeThread; | |
484 | 90 | DrawIMEModeThread = NULL; |
485 | 91 | } |
486 | 92 | if (CursorWindow != NULL) { |
487 | - delete CursorWindow; // Draw Window near by Mouse cursorの削除 | |
93 | + delete CursorWindow; | |
488 | 94 | CursorWindow = NULL; |
489 | 95 | } |
490 | 96 | if (IMECursorChangeThread != NULL) { |
491 | - delete IMECursorChangeThread; // IME Cursor Change Threadの後始末 | |
97 | + delete IMECursorChangeThread; | |
492 | 98 | IMECursorChangeThread = NULL; |
493 | 99 | } |
494 | 100 | if (stIMECursorData.lpszLoadDatName != NULL) { |
495 | - delete[] stIMECursorData.lpszLoadDatName; | |
101 | + delete [] stIMECursorData.lpszLoadDatName; | |
496 | 102 | stIMECursorData.lpszLoadDatName = NULL; |
497 | 103 | } |
498 | 104 | } |
@@ -528,7 +134,7 @@ BOOL CCursor::bInitialize(HWND hWnd) | ||
528 | 134 | if (!bChangeFlushMouseCursor(IMEOFF, &stIMECursorData)) return FALSE; |
529 | 135 | if (!bRegisterIMECursorChangeThread(hWnd)) return FALSE; |
530 | 136 | |
531 | -#define WINDOWCLASS _T("FlushMouseCursorWindow-{9395A3BE-4280-4AA1-9099-ADD712F982A1}") | |
137 | +#define WINDOWCLASS _T("FlushMouseCursorWindow-{E598B54C-A36A-4CDF-BC77-7082CEEDAA46}") | |
532 | 138 | if (CursorWindow == NULL) { |
533 | 139 | CursorWindow = new CCursorWindow; |
534 | 140 | if (!CursorWindow->bRegister((HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), WINDOWCLASS, stIMECursorData.dwNearDrawMouseColor)) return FALSE; |
@@ -536,8 +142,7 @@ BOOL CCursor::bInitialize(HWND hWnd) | ||
536 | 142 | DrawIMEModeThread = new CThread; |
537 | 143 | } |
538 | 144 | #undef WINDOWCLASS |
539 | - | |
540 | -#define WINDOWCLASS _T("FlushMouseCaretWindow-{D40AF72E-E0D9-47DA-8A0E-7E29F6F763E4}") | |
145 | +#define WINDOWCLASS _T("FlushMouseCaretWindow-{E598B54C-A36A-4CDF-BC77-7082CEEDAA46}") | |
541 | 146 | if (CaretWindow == NULL) { |
542 | 147 | CaretWindow = new CCursorWindow; |
543 | 148 | if (!CaretWindow->bRegister((HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), WINDOWCLASS, stIMECursorData.dwNearDrawCaretColor)) return FALSE; |
@@ -548,7 +153,6 @@ BOOL CCursor::bInitialize(HWND hWnd) | ||
548 | 153 | |
549 | 154 | if (!bRegisterDrawIMEModeThread(hWnd)) return FALSE; |
550 | 155 | if (!bStartIMECursorChangeThread(hWnd)) return FALSE; |
551 | - | |
552 | 156 | return TRUE; |
553 | 157 | } |
554 | 158 |
@@ -559,43 +163,52 @@ LPTSTR CCursor::lpszGetCursorDataName() | ||
559 | 163 | { |
560 | 164 | LPTSTR lpszCursorDataName = NULL; |
561 | 165 | LPTSTR lpszBuffer = new TCHAR[_MAX_PATH]; |
562 | - ZeroMemory(lpszBuffer, _MAX_PATH); | |
563 | - DWORD dwSize = 0; | |
564 | - GetCurrentDirectory(_MAX_PATH, lpszBuffer); | |
565 | - _tcsncat_s(lpszBuffer, _MAX_PATH, _T("\\"), sizeof(_T("\\"))); | |
566 | - _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDAT, sizeof(FLUSHMOUSECURSORDAT)); | |
567 | - dwSize = ExpandEnvironmentStrings(lpszBuffer, NULL, 0); | |
568 | - lpszCursorDataName = new TCHAR[dwSize]; | |
569 | - ZeroMemory(lpszCursorDataName, dwSize); | |
570 | - dwSize = ExpandEnvironmentStrings(lpszBuffer, lpszCursorDataName, dwSize); | |
571 | - if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { // Try Current Dir | |
572 | - delete [] lpszCursorDataName; | |
166 | + if (lpszBuffer) { | |
573 | 167 | ZeroMemory(lpszBuffer, _MAX_PATH); |
574 | - _tcsncat_s(lpszBuffer, _MAX_PATH, _T("%APPDATA%"), sizeof(_T("%APPDATA%"))); | |
575 | - _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDIR, sizeof(FLUSHMOUSECURSORDIR)); | |
168 | + DWORD dwSize = 0; | |
169 | + GetCurrentDirectory(_MAX_PATH, lpszBuffer); | |
170 | + _tcsncat_s(lpszBuffer, _MAX_PATH, _T("\\"), sizeof(_T("\\"))); | |
576 | 171 | _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDAT, sizeof(FLUSHMOUSECURSORDAT)); |
577 | 172 | dwSize = ExpandEnvironmentStrings(lpszBuffer, NULL, 0); |
578 | 173 | lpszCursorDataName = new TCHAR[dwSize]; |
579 | - ZeroMemory(lpszCursorDataName, dwSize); | |
580 | - dwSize = ExpandEnvironmentStrings(lpszBuffer, lpszCursorDataName, dwSize); | |
581 | - if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { // Try %APPDATA% Dir | |
582 | - delete [] lpszCursorDataName; | |
583 | - ZeroMemory(lpszBuffer, _MAX_PATH); | |
584 | - _tcsncat_s(lpszBuffer, _MAX_PATH, _T("%ALLUSERSPROFILE%"), sizeof(_T("%ALLUSERSPROFILE%"))); | |
585 | - _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDIR, sizeof(FLUSHMOUSECURSORDIR)); | |
586 | - _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDAT, sizeof(FLUSHMOUSECURSORDAT)); | |
587 | - dwSize = ExpandEnvironmentStrings(lpszBuffer, NULL, 0); | |
588 | - lpszCursorDataName = new TCHAR[dwSize]; | |
174 | + if (lpszCursorDataName) { | |
589 | 175 | ZeroMemory(lpszCursorDataName, dwSize); |
590 | 176 | dwSize = ExpandEnvironmentStrings(lpszBuffer, lpszCursorDataName, dwSize); |
591 | - if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { // Try %ALLUSERSPROFILE% Dir | |
592 | - delete [] lpszBuffer; | |
593 | - delete [] lpszCursorDataName; | |
594 | - return NULL; | |
177 | + if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { | |
178 | + delete[] lpszCursorDataName; | |
179 | + lpszCursorDataName = NULL; | |
180 | + ZeroMemory(lpszBuffer, _MAX_PATH); | |
181 | + _tcsncat_s(lpszBuffer, _MAX_PATH, _T("%APPDATA%"), sizeof(_T("%APPDATA%"))); | |
182 | + _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDIR, sizeof(FLUSHMOUSECURSORDIR)); | |
183 | + _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDAT, sizeof(FLUSHMOUSECURSORDAT)); | |
184 | + dwSize = ExpandEnvironmentStrings(lpszBuffer, NULL, 0); | |
185 | + lpszCursorDataName = new TCHAR[dwSize]; | |
186 | + if (lpszCursorDataName) { | |
187 | + ZeroMemory(lpszCursorDataName, dwSize); | |
188 | + dwSize = ExpandEnvironmentStrings(lpszBuffer, lpszCursorDataName, dwSize); | |
189 | + if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { | |
190 | + delete[] lpszCursorDataName; | |
191 | + lpszCursorDataName = NULL; | |
192 | + ZeroMemory(lpszBuffer, _MAX_PATH); | |
193 | + _tcsncat_s(lpszBuffer, _MAX_PATH, _T("%ALLUSERSPROFILE%"), sizeof(_T("%ALLUSERSPROFILE%"))); | |
194 | + _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDIR, sizeof(FLUSHMOUSECURSORDIR)); | |
195 | + _tcsncat_s(lpszBuffer, _MAX_PATH, FLUSHMOUSECURSORDAT, sizeof(FLUSHMOUSECURSORDAT)); | |
196 | + dwSize = ExpandEnvironmentStrings(lpszBuffer, NULL, 0); | |
197 | + lpszCursorDataName = new TCHAR[dwSize]; | |
198 | + if (lpszCursorDataName) { | |
199 | + ZeroMemory(lpszCursorDataName, dwSize); | |
200 | + dwSize = ExpandEnvironmentStrings(lpszBuffer, lpszCursorDataName, dwSize); | |
201 | + if (GetFileAttributes(lpszCursorDataName) == INVALID_FILE_ATTRIBUTES) { | |
202 | + delete[] lpszCursorDataName; | |
203 | + lpszCursorDataName = NULL; | |
204 | + } | |
205 | + } | |
206 | + } | |
207 | + } | |
595 | 208 | } |
596 | 209 | } |
210 | + delete[] lpszBuffer; | |
597 | 211 | } |
598 | - delete [] lpszBuffer; | |
599 | 212 | return lpszCursorDataName; |
600 | 213 | } |
601 | 214 |
@@ -639,6 +252,16 @@ BOOL CCursor::bStartDrawIMEModeThreadWait(HWND hWndObserved) | ||
639 | 252 | } |
640 | 253 | |
641 | 254 | // |
255 | +// bStartDrawIMEModeThreadWaitEventForeGround() | |
256 | +// | |
257 | +BOOL CCursor::bStartDrawIMEModeThreadWaitEventForeGround(HWND hWndObserved) | |
258 | +{ | |
259 | + stIMECursorData.bDrawIMEModeWait = TRUE; | |
260 | + stIMECursorData.dwWaitWaveTime = 100; | |
261 | + return _bStartDrawIMEModeThread(hWndObserved); | |
262 | +} | |
263 | + | |
264 | +// | |
642 | 265 | // bStartDrawIMEModeThreadWaitDblClk() |
643 | 266 | // |
644 | 267 | BOOL CCursor::bStartDrawIMEModeThreadWaitDblClk(HWND hWndObserved) |
@@ -649,17 +272,17 @@ BOOL CCursor::bStartDrawIMEModeThreadWaitDblClk(HWND hWndObserved) | ||
649 | 272 | } |
650 | 273 | |
651 | 274 | // |
652 | -// _bStartDrawIMEModeThreadWait() | |
275 | +// _bStartDrawIMEModeThread() | |
653 | 276 | // |
654 | 277 | BOOL CCursor::_bStartDrawIMEModeThread(HWND hWndObserved) |
655 | 278 | { |
656 | - if ((Cursor == NULL) || (DrawIMEModeThread == NULL)) return FALSE; | |
279 | + if ((Cursor == NULL) || (DrawIMEModeThread == NULL)) return FALSE; | |
657 | 280 | stIMECursorData.hWnd = _hGetCaretPosByAccessibleObjectFromWindow(hWndObserved, &stIMECursorData.rcCaret); |
658 | 281 | stIMECursorData.hWndObserved = hWndObserved; |
659 | 282 | stIMECursorData.bDisplayFocusWindowIME = bDisplayFocusWindowIME; |
660 | 283 | if (!DrawIMEModeThread->bStart()) { |
661 | 284 | if (DrawIMEModeThread != NULL) { |
662 | - delete DrawIMEModeThread; // Draw IME Mode Threadの後始末 | |
285 | + delete DrawIMEModeThread; | |
663 | 286 | DrawIMEModeThread = NULL; |
664 | 287 | } |
665 | 288 | DrawIMEModeThread = new CThread; |
@@ -673,7 +296,7 @@ BOOL CCursor::_bStartDrawIMEModeThread(HWND hWndObserved) | ||
673 | 296 | // |
674 | 297 | BOOL CCursor::bShowHideCursor(HWND hWndObserved, BOOL bShow) |
675 | 298 | { |
676 | - BOOL bRet = FALSE; | |
299 | + BOOL bRet = FALSE; | |
677 | 300 | if (bShow) { |
678 | 301 | bRet = bStartDrawIMEModeThread(hWndObserved); |
679 | 302 | } |
@@ -688,10 +311,10 @@ BOOL CCursor::bShowHideCursor(HWND hWndObserved, BOOL bShow) | ||
688 | 311 | // |
689 | 312 | BOOL CCursor::bGetCaretPos(HWND hWnd, LPPOINT lpCaretPos) |
690 | 313 | { |
691 | - BOOL bRet = FALSE; | |
692 | - RECT rc{}; | |
314 | + BOOL bRet = FALSE; | |
315 | + RECT rc{}; | |
693 | 316 | lpCaretPos->x = 0; lpCaretPos->y = 0; |
694 | - if (_hGetCaretPosByGuiThreadInfo(hWnd, &rc) != NULL) { | |
317 | + if (_hGetCaretPosByAccessibleObjectFromWindow(hWnd, &rc) != NULL) { | |
695 | 318 | bRet = TRUE; |
696 | 319 | } |
697 | 320 | if (stIMECursorData.hWnd != NULL) { |
@@ -738,14 +361,11 @@ BOOL CCursor::bCursorDllUnload() | ||
738 | 361 | // |
739 | 362 | BOOL CCursor::bSystemCursorLoad() |
740 | 363 | { |
741 | - // Set Flush Mouse Cursor to System | |
742 | 364 | if (!bChangeFlushMouseCursor(IMEOFF, &stIMECursorData)) return FALSE; |
743 | 365 | |
744 | - // Set Other Mouse Cursor to System | |
745 | 366 | int i = 0; |
746 | 367 | while (stAllMouseCursor[i].id != (DWORD)(-1)) { |
747 | 368 | if (stAllMouseCursor[i].bReadReg) { |
748 | - // Get Other System Cursor Filename from Registry | |
749 | 369 | if (!bGetMouseRegValue(stAllMouseCursor[i].szRegValue, stAllMouseCursor[i].szFile)) return FALSE; |
750 | 370 | } |
751 | 371 | i++; |
@@ -772,7 +392,7 @@ BOOL CCursor::bRegisterIMECursorChangeThread(HWND hWndObserved) | ||
772 | 392 | BOOL CCursor::bIMECursorChangeRoutine(LPVOID lpvParam) |
773 | 393 | { |
774 | 394 | LPIMECURSORDATA lpstCursorData = (LPIMECURSORDATA)lpvParam; |
775 | - CCursor* This = reinterpret_cast<CCursor*>(lpvParam); | |
395 | + CCursor *This = reinterpret_cast<CCursor*>(lpvParam); | |
776 | 396 | BOOL bRet = TRUE; |
777 | 397 | if (lpstCursorData->bDisplayIMEModeOnCursor) { |
778 | 398 | This->bIsIMECursorChanged(lpstCursorData); |
@@ -808,16 +428,19 @@ BOOL CCursor::bRegisterDrawIMEModeThread(HWND hWndObserved) | ||
808 | 428 | BOOL WINAPI CCursor::bDrawIMEModeRoutine(LPVOID lpvParam) |
809 | 429 | { |
810 | 430 | LPIMECURSORDATA lpstCursorData = (LPIMECURSORDATA)lpvParam; |
811 | - CCursor* This = reinterpret_cast<CCursor*>(lpvParam); | |
431 | + CCursor *This = reinterpret_cast<CCursor*>(lpvParam); | |
432 | + BOOL bRet = TRUE; | |
812 | 433 | This->bIsIMECursorChanged(lpstCursorData); |
813 | 434 | if (!This->bDrawIMEModeOnDisplay(lpstCursorData)) { |
814 | 435 | _Post_equals_last_error_ DWORD err = GetLastError(); |
815 | 436 | if (err == ERROR_ACCESS_DENIED) { |
816 | - return FALSE; | |
437 | + bRet = TRUE; | |
438 | + } | |
439 | + else { | |
440 | + bRet = FALSE; | |
817 | 441 | } |
818 | - return FALSE; | |
819 | 442 | } |
820 | - return TRUE; | |
443 | + return bRet; | |
821 | 444 | } |
822 | 445 | |
823 | 446 | // |
@@ -830,7 +453,7 @@ BOOL CCursor::bIsIMECursorChanged(LPIMECURSORDATA lpstCursorData) | ||
830 | 453 | dwIMEMode = Cime->dwIMEMode(lpstCursorData->hWndObserved, lpstCursorData->bForceHiragana); |
831 | 454 | if (lpstCursorData->dwIMEModeCursor == dwIMEMode) return FALSE; |
832 | 455 | lpstCursorData->dwIMEModeCursor = dwIMEMode; |
833 | - return TRUE; | |
456 | + return TRUE; | |
834 | 457 | } |
835 | 458 | |
836 | 459 | // |
@@ -841,7 +464,7 @@ BOOL CCursor::bDrawIMEModeOnDisplay(LPIMECURSORDATA lpstCursorData) | ||
841 | 464 | BOOL bRet = FALSE; |
842 | 465 | RECT rc{}; |
843 | 466 | if (lpstCursorData->bDrawIMEModeWait) { |
844 | - if (lpstCursorData->dwWaitWaveTime != 0) Sleep(lpstCursorData->dwWaitWaveTime); | |
467 | + if (lpstCursorData->dwWaitWaveTime != 0) Sleep(lpstCursorData->dwWaitWaveTime); | |
845 | 468 | } |
846 | 469 | if (_bCalcDispModeRect(lpstCursorData->iModeSize, lpstCursorData->iModeSize, &rc)) { |
847 | 470 | if (EnumDisplayMonitors(NULL, &rc, (MONITORENUMPROC)&bIconDrawEnumProc, (LPARAM)lpstCursorData) != 0) { |
@@ -885,7 +508,6 @@ BOOL CCursor::bIconDrawEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, L | ||
885 | 508 | BOOL CCursor::_bCalcDispModeRect(int iModeSizeX, int iModeSizeY, LPRECT lpRect) |
886 | 509 | { |
887 | 510 | POINT pt{}; |
888 | - RECT rect{}; | |
889 | 511 | if (GetCursorPos(&pt)) { |
890 | 512 | HMONITOR hMonitor = NULL; |
891 | 513 | if ((hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST)) != NULL) { |
@@ -894,7 +516,6 @@ BOOL CCursor::_bCalcDispModeRect(int iModeSizeX, int iModeSizeY, LPRECT lpRect) | ||
894 | 516 | int iIconSizeX = 0, iIconSizeY = 0; |
895 | 517 | iIconSizeX = iModeSizeX * (dpiX + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI + 1; |
896 | 518 | iIconSizeY = iModeSizeY * (dpiY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI + 1; |
897 | - // Draw near by Mouse cursor Left | |
898 | 519 | lpRect->left = pt.x - ((iIconSizeX * 3 + 1) / 2); lpRect->right = lpRect->left + iIconSizeX; |
899 | 520 | lpRect->top = pt.y - ((iIconSizeY + 1) / 2); lpRect->bottom = lpRect->top + iIconSizeY; |
900 | 521 | return TRUE; |
@@ -913,85 +534,72 @@ BOOL CCursor::_bCalcDispModeRect(int iModeSizeX, int iModeSizeY, LPRECT lpRect) | ||
913 | 534 | } |
914 | 535 | |
915 | 536 | // |
916 | -// _hGetCarePosByAccessibleObjectFromWindow() | |
917 | -// | |
537 | +// _hGetCaretPosByAccessibleObjectFromWindow() | |
538 | +// | |
918 | 539 | HWND CCursor::_hGetCaretPosByAccessibleObjectFromWindow(HWND hForeWnd, LPRECT lpRect) |
919 | 540 | { |
541 | + HWND hWnd = NULL; | |
920 | 542 | POINT pt{}; |
921 | - RECT rcFore{}, rcTop{}; | |
922 | 543 | DWORD dwPID = 0, dwForeThreadID = 0; |
923 | 544 | if (hForeWnd != NULL) { |
924 | - if ((dwForeThreadID = GetWindowThreadProcessId(hForeWnd, &dwPID)) != 0) { | |
925 | - GUITHREADINFO GuiThreadInfo{}; GuiThreadInfo.cbSize = sizeof(GUITHREADINFO); | |
926 | - if (GetGUIThreadInfo(dwForeThreadID, &GuiThreadInfo)) { | |
927 | - IAccessible* IAccessible = NULL; | |
928 | - if (GuiThreadInfo.hwndFocus != NULL) { | |
929 | - HRESULT hResult = AccessibleObjectFromWindow(GuiThreadInfo.hwndFocus, (DWORD)OBJID_CARET, IID_IAccessible, (LPVOID*)&IAccessible); | |
930 | - if (hResult == S_OK) { | |
931 | - SIZE sz{}; | |
932 | - VARIANT variant{}; variant.vt = VT_I4; variant.lVal = CHILDID_SELF; | |
933 | - if ((hResult = IAccessible->accLocation(&pt.x, &pt.y, &sz.cx, &sz.cy, variant)) == S_OK) { | |
934 | - IAccessible->Release(); | |
935 | - lpRect->left = pt.x; lpRect->top = pt.y; lpRect->right = pt.x + sz.cx; lpRect->bottom = pt.y + sz.cy; | |
936 | -#define MARGIN 2 | |
937 | - if (((pt.x == 0) && (pt.y == 0)) || (pt.x <= rcTop.left + MARGIN) || (pt.y <= rcTop.top + MARGIN) || (pt.x <= rcFore.left) || (pt.y <= rcFore.top)) { | |
938 | -#undef MARGIN | |
939 | - lpRect->left = 0; lpRect->right = 0; | |
940 | - lpRect->top = 0; lpRect->bottom = 0; | |
941 | - return NULL; | |
942 | - } | |
943 | - else { | |
944 | - return GuiThreadInfo.hwndFocus; | |
945 | - } | |
946 | - } | |
947 | - } | |
948 | - } | |
949 | - } | |
950 | - } | |
951 | - } | |
952 | - return NULL; | |
953 | -} | |
954 | - | |
955 | -// | |
956 | -// _hGetCaretPosByGuiThreadInfo() | |
957 | -// | |
958 | -HWND CCursor::_hGetCaretPosByGuiThreadInfo(HWND hForeWnd, LPRECT lpRect) | |
959 | -{ | |
960 | - POINT pt{}; | |
961 | - RECT rcFore{}, rcTop{}; | |
962 | - DWORD dwPID = 0, dwForeThreadID = 0; | |
963 | - if (hForeWnd != NULL) { | |
964 | - if (GetWindowRect(hForeWnd, &rcFore)) { | |
965 | 545 | if ((dwForeThreadID = GetWindowThreadProcessId(hForeWnd, &dwPID)) != 0) { |
966 | - GUITHREADINFO GuiThreadInfo{}; GuiThreadInfo.cbSize = sizeof(GUITHREADINFO); | |
967 | - if (GetGUIThreadInfo(dwForeThreadID, &GuiThreadInfo)) { | |
968 | - if (GuiThreadInfo.hwndCaret != NULL) { | |
969 | - pt.x = GuiThreadInfo.rcCaret.left; pt.y = GuiThreadInfo.rcCaret.top; | |
970 | - if (ClientToScreen(GuiThreadInfo.hwndCaret, &pt)) { | |
971 | - lpRect->left = pt.x; lpRect->top = pt.y; | |
972 | - pt.x = GuiThreadInfo.rcCaret.right; pt.y = GuiThreadInfo.rcCaret.bottom; | |
973 | - if (ClientToScreen(GuiThreadInfo.hwndCaret, &pt)) { | |
974 | - lpRect->right = pt.x; lpRect->bottom = pt.y; | |
975 | - if (GetWindowRect(GuiThreadInfo.hwndCaret, &rcTop)) { | |
976 | -#define MARGIN 2 | |
977 | - if (((pt.x == 0) && (pt.y == 0)) || (pt.x <= rcTop.left + MARGIN) || (pt.y <= rcTop.top + MARGIN) || (pt.x <= rcFore.left) || (pt.y <= rcFore.top)) { | |
978 | -#undef MARGIN | |
979 | - lpRect->left = 0; lpRect->right = 0; | |
980 | - lpRect->top = 0; lpRect->bottom = 0; | |
981 | - return NULL; | |
546 | + LPGUITHREADINFO lpGuiThreadInfo = new GUITHREADINFO[sizeof(GUITHREADINFO)]; | |
547 | + if (lpGuiThreadInfo != NULL) { | |
548 | + lpGuiThreadInfo->cbSize = sizeof(GUITHREADINFO); | |
549 | + if (GetGUIThreadInfo(dwForeThreadID, lpGuiThreadInfo)) { | |
550 | + IAccessible* IAccessible = NULL; | |
551 | + if (lpGuiThreadInfo->hwndFocus != NULL) { | |
552 | + HRESULT hResult = AccessibleObjectFromWindow(lpGuiThreadInfo->hwndFocus, (DWORD)OBJID_CARET, IID_IAccessible, (LPVOID*)&IAccessible); | |
553 | + if (hResult == S_OK) { | |
554 | + LPVARIANT lpVariant = new VARIANT[sizeof(VARIANT)]; | |
555 | + if (lpVariant != NULL) { | |
556 | + SIZE sz{}; | |
557 | + lpVariant->vt = VT_I4; lpVariant->lVal = CHILDID_SELF; | |
558 | + if ((hResult = IAccessible->accLocation(&pt.x, &pt.y, &sz.cx, &sz.cy, *lpVariant)) == S_OK) { | |
559 | + IAccessible->Release(); | |
560 | + lpRect->left = pt.x; lpRect->top = pt.y; lpRect->right = pt.x + sz.cx; lpRect->bottom = pt.y + sz.cy; | |
561 | + if ((pt.x == 0) && (pt.y == 0) && (sz.cx == 0) && (sz.cy == 0)) { | |
562 | + lpRect->left = 0; lpRect->right = 0; lpRect->top = 0; lpRect->bottom = 0; | |
563 | + hWnd = NULL; | |
564 | + } | |
565 | + else { | |
566 | + hWnd = lpGuiThreadInfo->hwndFocus; | |
567 | + } | |
982 | 568 | } |
983 | 569 | else { |
984 | - return GuiThreadInfo.hwndCaret; | |
570 | + if (lpGuiThreadInfo->hwndCaret != NULL) { | |
571 | + pt.x = lpGuiThreadInfo->rcCaret.left; pt.y = lpGuiThreadInfo->rcCaret.top; | |
572 | + if (ClientToScreen(lpGuiThreadInfo->hwndCaret, &pt)) { | |
573 | + lpRect->left = pt.x; lpRect->top = pt.y; | |
574 | + pt.x = lpGuiThreadInfo->rcCaret.right; pt.y = lpGuiThreadInfo->rcCaret.bottom; | |
575 | + if (ClientToScreen(lpGuiThreadInfo->hwndCaret, &pt)) { | |
576 | + lpRect->right = pt.x; lpRect->bottom = pt.y; | |
577 | + RECT rcFore{}, rcTop{}; | |
578 | + if (GetWindowRect(lpGuiThreadInfo->hwndCaret, &rcTop)) { | |
579 | +#define MARGIN 2 | |
580 | + if (((pt.x == 0) && (pt.y == 0)) || (pt.x <= rcTop.left + MARGIN) || (pt.y <= rcTop.top + MARGIN) || (pt.x <= rcFore.left) || (pt.y <= rcFore.top)) { | |
581 | +#undef MARGIN | |
582 | + lpRect->left = 0; lpRect->right = 0; lpRect->top = 0; lpRect->bottom = 0; | |
583 | + hWnd = NULL; | |
584 | + } | |
585 | + else { | |
586 | + hWnd = lpGuiThreadInfo->hwndCaret; | |
587 | + } | |
588 | + } | |
589 | + } | |
590 | + } | |
591 | + } | |
985 | 592 | } |
593 | + delete[] lpVariant; | |
986 | 594 | } |
987 | 595 | } |
988 | 596 | } |
989 | 597 | } |
598 | + delete [] lpGuiThreadInfo; | |
990 | 599 | } |
991 | 600 | } |
992 | - } | |
993 | 601 | } |
994 | - return NULL; | |
602 | + return hWnd; | |
995 | 603 | } |
996 | 604 | |
997 | 605 | // |
@@ -1012,11 +620,12 @@ BOOL CCursor::_bAdjustCaretByMonitorDPI(int iModeSizeX, int iModeSizeY, LPRECT | ||
1012 | 620 | lpRect->right = lpRect->left + iIconSizeX; |
1013 | 621 | if ((lpRect->bottom - lpRect->top) < iModeSizeY) { |
1014 | 622 | lpRect->top = (lpRect->bottom - iIconSizeY) + (DESCENT * (dpiY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); |
623 | + lpRect->bottom = lpRect->top + iIconSizeY; | |
1015 | 624 | } |
1016 | 625 | else { |
1017 | - lpRect->top = (lpRect->bottom - ((lpRect->bottom - lpRect->top) / 2) - (iIconSizeY / 2));// + (DESCENT * (dpiY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
626 | + lpRect->top = (lpRect->bottom - ((lpRect->bottom - lpRect->top) / 2 ) - (iIconSizeY / 2));// + (DESCENT * (dpiY + USER_DEFAULT_SCREEN_DPI - 1) / USER_DEFAULT_SCREEN_DPI); | |
627 | + lpRect->bottom = lpRect->top + iIconSizeY; | |
1018 | 628 | } |
1019 | - lpRect->bottom = lpRect->top + iIconSizeY; | |
1020 | 629 | #undef DESCENT |
1021 | 630 | return TRUE; |
1022 | 631 | } |
@@ -1024,15 +633,18 @@ BOOL CCursor::_bAdjustCaretByMonitorDPI(int iModeSizeX, int iModeSizeY, LPRECT | ||
1024 | 633 | return FALSE; |
1025 | 634 | } |
1026 | 635 | |
636 | +// | |
637 | +// bDrawIMEModeOnDisplaySub() | |
638 | +// | |
1027 | 639 | BOOL CCursor::bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData) |
1028 | 640 | { |
1029 | 641 | Sleep(50); |
1030 | - | |
1031 | - BOOL bFoundCaret = FALSE; | |
1032 | - RECT rcCursor{}, rcCaret{}; | |
642 | + | |
643 | + BOOL bFoundCaret = FALSE; | |
644 | + RECT rcCursor{}, rcCaret{}; | |
1033 | 645 | int iCursorSizeX = 0, iCursorSizeY = 0, iCaretSizeX = 0, iCaretSizeY = 0; |
1034 | 646 | DWORD dwIMEModeCursor = IMEOFF, dwIMEModeCaret = IMEOFF; |
1035 | - HWND hCaretWnd = NULL; | |
647 | + HWND hCaretWnd = NULL; | |
1036 | 648 | if (lpstCursorData->bDrawNearCaret != FALSE) { |
1037 | 649 | if (lpstCursorData->hWnd != NULL) { |
1038 | 650 | rcCaret.left = lpstCursorData->rcCaret.left; rcCaret.top = lpstCursorData->rcCaret.top; |
@@ -1040,7 +652,7 @@ BOOL CCursor::bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData) | ||
1040 | 652 | hCaretWnd = lpstCursorData->hWnd; |
1041 | 653 | bFoundCaret = TRUE; |
1042 | 654 | } |
1043 | - else if ((hCaretWnd = _hGetCaretPosByGuiThreadInfo(GetForegroundWindow(), &rcCaret)) != NULL) { | |
655 | + else if ((hCaretWnd = _hGetCaretPosByAccessibleObjectFromWindow(GetForegroundWindow(), &rcCaret)) != NULL) { | |
1044 | 656 | bFoundCaret = TRUE; |
1045 | 657 | } |
1046 | 658 | if (bFoundCaret && (hCaretWnd != NULL)) { |
@@ -1088,8 +700,8 @@ BOOL CCursor::bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData) | ||
1088 | 700 | } |
1089 | 701 | |
1090 | 702 | #define COUNT 10 |
1091 | - BOOL bRet = FALSE; | |
1092 | - int iCount = 0; | |
703 | + BOOL bRet = FALSE; | |
704 | + int iCount = 0; | |
1093 | 705 | if (lpstCursorData->dwDisplayModeTime != 0) iCount = (lpstCursorData->dwDisplayModeTime + (COUNT - 1)) / COUNT; |
1094 | 706 | else iCount = COUNT; |
1095 | 707 | for (; iCount >= 0; iCount--) { |
@@ -1114,12 +726,10 @@ BOOL CCursor::bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData) | ||
1114 | 726 | Sleep(COUNT); |
1115 | 727 | bRet = TRUE; |
1116 | 728 | } |
1117 | - | |
1118 | 729 | if (!CursorWindow->bSetWindowPos(HWND_BOTTOM, rcCursor.left, rcCursor.top, iCursorSizeX, iCursorSizeY, (SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS))) { |
1119 | 730 | bRet = FALSE; |
1120 | 731 | } |
1121 | 732 | CursorWindow->vSetModeString(lpstCursorData->lpstFlushMouseCursor[0].szMode); |
1122 | - | |
1123 | 733 | if (bFoundCaret) { |
1124 | 734 | if (!CaretWindow->bSetWindowPos(HWND_BOTTOM, rcCaret.left, rcCaret.top, iCaretSizeX, iCaretSizeY, (SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS))) { |
1125 | 735 | bRet = FALSE; |
@@ -1134,11 +744,10 @@ BOOL CCursor::bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData) | ||
1134 | 744 | // |
1135 | 745 | BOOL CCursor::bGetMouseRegValue(LPCTSTR szValue, LPTSTR szFile) |
1136 | 746 | { |
1137 | -// \HKEY_CURRENT_USER\Control Panel\Cursors | |
1138 | 747 | #define MOUSE_HKEY HKEY_CURRENT_USER |
1139 | 748 | #define MOUSE_SUBKEY _T("Control Panel\\Cursors") |
1140 | - BOOL bRet = FALSE; | |
1141 | - CRegistry* CReg = new CRegistry; | |
749 | + BOOL bRet = FALSE; | |
750 | + CRegistry *CReg = new CRegistry; | |
1142 | 751 | if (CReg->bReadRegValueString(MOUSE_HKEY, MOUSE_SUBKEY, szValue, szFile, _MAX_PATH)) { |
1143 | 752 | bRet = TRUE; |
1144 | 753 | } |
@@ -1160,7 +769,7 @@ BOOL CCursor::bChangeFlushMouseCursor(UINT uCurID, LPIMECURSORDATA lpstCursorDa | ||
1160 | 769 | if (bSetSystemCursor((LPMOUSECURSOR)&(lpstCursorData->lpstFlushMouseCursor[i]).stArrow, lpstCursorData->iCursorSize, lpstCursorData->iCursorSize)) { |
1161 | 770 | if (bSetSystemCursor((LPMOUSECURSOR) & (lpstCursorData->lpstFlushMouseCursor[i]).stHand, lpstCursorData->iCursorSize, lpstCursorData->iCursorSize)) { |
1162 | 771 | if (bSetSystemCursor((LPMOUSECURSOR) & (lpstCursorData->lpstFlushMouseCursor[i]).stIBeam, lpstCursorData->iCursorSize, lpstCursorData->iCursorSize)) { |
1163 | - return TRUE; // Success | |
772 | + return TRUE; | |
1164 | 773 | } |
1165 | 774 | } |
1166 | 775 | } |
@@ -1172,29 +781,32 @@ BOOL CCursor::bChangeFlushMouseCursor(UINT uCurID, LPIMECURSORDATA lpstCursorDa | ||
1172 | 781 | // |
1173 | 782 | BOOL CCursor::bSetSystemCursor(LPMOUSECURSOR lpstMC, int iCursorSizeX, int iCursorSizeY) |
1174 | 783 | { |
1175 | - HCURSOR hCur; | |
1176 | - UINT fuLoad = 0; | |
1177 | - if (lpstMC->bReadReg) { // Load Cursor from registry | |
1178 | - if (lpstMC->szFile[0] == '\0') return TRUE; | |
784 | + HCURSOR hCur; | |
785 | + UINT fuLoad = 0; | |
786 | + if (lpstMC->bReadReg) { | |
787 | + if (lpstMC->szFile[0] == '\0') return TRUE; | |
1179 | 788 | fuLoad = (LR_VGACOLOR | LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); |
1180 | 789 | if ((hCur = (HCURSOR)LoadImage(NULL, lpstMC->szFile, IMAGE_CURSOR, iCursorSizeX, iCursorSizeY, fuLoad)) == NULL) { |
1181 | 790 | return FALSE; |
1182 | 791 | } |
1183 | 792 | } else { |
1184 | - if (lpstMC->uResourceID == 0) { // Load Cursor from file | |
793 | + if (lpstMC->uResourceID == 0) { | |
1185 | 794 | if (lpstMC->szFile[0] == '\0') return FALSE; |
1186 | 795 | DWORD dwSize = 0; |
1187 | 796 | dwSize = ExpandEnvironmentStrings(lpstMC->szFile, NULL, 0); |
1188 | 797 | LPTSTR lpszBuffer = new TCHAR[dwSize]; |
1189 | - ZeroMemory(lpszBuffer, dwSize); | |
1190 | - dwSize = ExpandEnvironmentStrings(lpstMC->szFile, lpszBuffer, dwSize); | |
1191 | - fuLoad = (LR_VGACOLOR | LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); | |
1192 | - if ((hCur = (HCURSOR)LoadImage(NULL, lpszBuffer, IMAGE_CURSOR, iCursorSizeX, iCursorSizeY, fuLoad)) == NULL) { | |
1193 | - delete [] lpszBuffer; | |
1194 | - return FALSE; | |
798 | + if (lpszBuffer) { | |
799 | + ZeroMemory(lpszBuffer, dwSize); | |
800 | + dwSize = ExpandEnvironmentStrings(lpstMC->szFile, lpszBuffer, dwSize); | |
801 | + fuLoad = (LR_VGACOLOR | LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); | |
802 | + if ((hCur = (HCURSOR)LoadImage(NULL, lpszBuffer, IMAGE_CURSOR, iCursorSizeX, iCursorSizeY, fuLoad)) == NULL) { | |
803 | + delete[] lpszBuffer; | |
804 | + return FALSE; | |
805 | + } | |
806 | + delete[] lpszBuffer; | |
1195 | 807 | } |
1196 | - delete[] lpszBuffer; | |
1197 | - } else { // Load Cursor from DLL | |
808 | + else return FALSE; | |
809 | + } else { | |
1198 | 810 | HMODULE hMod = NULL; |
1199 | 811 | if ((hMod = hCursorDllLoad()) == NULL) return FALSE; |
1200 | 812 | fuLoad = (LR_VGACOLOR | LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION); |
@@ -1208,11 +820,12 @@ BOOL CCursor::bSetSystemCursor(LPMOUSECURSOR lpstMC, int iCursorSizeX, int iCur | ||
1208 | 820 | if (!bCursorDllUnload()) return FALSE; |
1209 | 821 | return FALSE; |
1210 | 822 | } |
823 | + // Unload Cursor data DLL | |
1211 | 824 | if (!bCursorDllUnload()) return FALSE; |
1212 | 825 | } |
1213 | 826 | } |
1214 | 827 | if (!SetSystemCursor(hCur, lpstMC->id)) return FALSE; |
1215 | - DestroyCursor(hCur); | |
828 | + DestroyCursor(hCur); | |
1216 | 829 | return TRUE; |
1217 | 830 | } |
1218 | 831 |
@@ -1231,12 +844,11 @@ CCursorWindow::CCursorWindow() | ||
1231 | 844 | CCursorWindow::~CCursorWindow() |
1232 | 845 | { |
1233 | 846 | if (hCursorWindow != NULL) { |
1234 | - DestroyWindow(hCursorWindow); | |
1235 | - UnregisterClass(lpszWindowClass, (HINSTANCE)GetWindowLongPtr(hCursorWindow, GWLP_HINSTANCE)); | |
847 | + PostMessage(hCursorWindow, WM_DESTROY, (WPARAM)0, (LPARAM)0); | |
1236 | 848 | hCursorWindow = NULL; |
1237 | 849 | } |
1238 | 850 | if (lpszWindowClass != NULL) { |
1239 | - delete[] lpszWindowClass; | |
851 | + delete [] lpszWindowClass; | |
1240 | 852 | lpszWindowClass = NULL; |
1241 | 853 | } |
1242 | 854 | } |
@@ -1248,20 +860,23 @@ BOOL CCursorWindow::bRegister(HINSTANCE hInstance, LPCTSTR szWindowClassName, C | ||
1248 | 860 | { |
1249 | 861 | if (hInstance == NULL) return FALSE; |
1250 | 862 | lpszWindowClass = new TCHAR[MAX_LOADSTRING]; |
1251 | - ZeroMemory(lpszWindowClass, MAX_LOADSTRING); | |
1252 | - _tcsncpy_s(lpszWindowClass, MAX_LOADSTRING, szWindowClassName, _TRUNCATE); | |
863 | + if (lpszWindowClass) { | |
864 | + ZeroMemory(lpszWindowClass, MAX_LOADSTRING); | |
865 | + _tcsncpy_s(lpszWindowClass, MAX_LOADSTRING, szWindowClassName, _TRUNCATE); | |
1253 | 866 | |
1254 | - dwTextColor = dwRGB; | |
1255 | - if (dwRGB & 0x00000100) dwBackColor = dwRGB & 0xfffffeff; | |
1256 | - else dwBackColor = dwRGB | 0x00000100; | |
867 | + dwTextColor = dwRGB; | |
868 | + if (dwRGB & 0x00000100) dwBackColor = dwRGB & 0xfffffeff; | |
869 | + else dwBackColor = dwRGB | 0x00000100; | |
1257 | 870 | |
1258 | - if (!MyRegisterClass(hInstance)) { | |
1259 | - return FALSE; | |
1260 | - } | |
1261 | - if ((hCursorWindow = InitInstance(hInstance, SW_HIDE)) == NULL) { | |
1262 | - return FALSE; | |
871 | + if (!MyRegisterClass(hInstance)) { | |
872 | + return FALSE; | |
873 | + } | |
874 | + if ((hCursorWindow = InitInstance(hInstance, SW_HIDE)) == NULL) { | |
875 | + return FALSE; | |
876 | + } | |
877 | + return TRUE; | |
1263 | 878 | } |
1264 | - return TRUE; | |
879 | + return FALSE; | |
1265 | 880 | } |
1266 | 881 | |
1267 | 882 | // |
@@ -1291,22 +906,22 @@ ATOM CCursorWindow::MyRegisterClass(HINSTANCE hInstance) | ||
1291 | 906 | #define CLASSSTYLE (CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE) |
1292 | 907 | WNDCLASSEX wcex{}; |
1293 | 908 | wcex.cbSize = sizeof(WNDCLASSEX); |
1294 | - wcex.style = CLASSSTYLE; // クラススタイル | |
1295 | - wcex.lpfnWndProc = WndProc; // Window Proc. | |
1296 | - wcex.cbClsExtra = 0; // クラスの補足データなし | |
1297 | - wcex.cbWndExtra = 0; // ウィンドウの補足データなし | |
1298 | - wcex.hInstance = hInstance; // クラスのウィンドウハンドル | |
1299 | - wcex.hIcon = NULL; // アイコンハンドル | |
1300 | - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); // マウスカーソルハンドル | |
1301 | - wcex.hbrBackground = NULL; // ウィンドウ背景色 | |
1302 | - wcex.lpszMenuName = NULL; // デフォルトメニュー名 | |
1303 | - wcex.lpszClassName = lpszWindowClass; // このウインドウクラスにつける名前 | |
1304 | - wcex.hIconSm = NULL; // 16×16の小さいサイズのアイコン | |
909 | + wcex.style = CLASSSTYLE; | |
910 | + wcex.lpfnWndProc = WndProc; | |
911 | + wcex.cbClsExtra = 0; | |
912 | + wcex.cbWndExtra = 0; | |
913 | + wcex.hInstance = hInstance; | |
914 | + wcex.hIcon = NULL; | |
915 | + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); | |
916 | + wcex.hbrBackground = NULL; | |
917 | + wcex.lpszMenuName = NULL; | |
918 | + wcex.lpszClassName = lpszWindowClass; | |
919 | + wcex.hIconSm = NULL; | |
1305 | 920 | |
1306 | 921 | ATOM atom = 0; |
1307 | 922 | if ((atom = RegisterClassEx(&wcex)) == 0) { |
1308 | 923 | _Post_equals_last_error_ DWORD err = GetLastError(); |
1309 | - if (err == 1410) return 1; // non error | |
924 | + if (err == 1410) return 1; | |
1310 | 925 | } |
1311 | 926 | return atom; |
1312 | 927 | } |
@@ -1319,20 +934,20 @@ HWND CCursorWindow::InitInstance(HINSTANCE hInstance, int nCmdShow) | ||
1319 | 934 | #define EX_WINDOWSTYLE (WS_EX_LAYERED | WS_EX_NOACTIVATE) |
1320 | 935 | #define WINDOWSTYLE (WS_POPUP) |
1321 | 936 | |
1322 | - HWND hWnd = NULL; // ウィンドウのハンドル | |
937 | + HWND hWnd = NULL; | |
1323 | 938 | hWnd = CreateWindowEx( |
1324 | - EX_WINDOWSTYLE, // 拡張ウィンドウスタイル | |
1325 | - lpszWindowClass, // RegisterClass()呼び出しを参照 | |
1326 | - NULL, // Title barのテキスト | |
1327 | - WINDOWSTYLE, // Window style | |
1328 | - 0, 0, // 水平・垂直位置 | |
1329 | - 0, 0, // 幅・高さ | |
1330 | - NULL, // 親オーバーラップウィンドウ | |
1331 | - NULL, // ウィンドウクラスのメニューを使う | |
1332 | - hInstance, // 所有インスタンス | |
1333 | - this); // 自分のポインタを渡す | |
939 | + EX_WINDOWSTYLE, | |
940 | + lpszWindowClass, | |
941 | + NULL, | |
942 | + WINDOWSTYLE, | |
943 | + 0, 0, | |
944 | + 0, 0, | |
945 | + NULL, | |
946 | + NULL, | |
947 | + hInstance, | |
948 | + this); | |
1334 | 949 | if (!hWnd) { |
1335 | - return NULL; // ウィンドウを作成できなかったときはNULLを返す | |
950 | + return NULL; | |
1336 | 951 | } |
1337 | 952 | ShowWindow(hWnd, nCmdShow); |
1338 | 953 | UpdateWindow(hWnd); |
@@ -1409,22 +1024,22 @@ void CCursorWindow::Cls_OnPaint(HWND hWnd) | ||
1409 | 1024 | RECT rc{}; |
1410 | 1025 | if (GetClientRect(hWnd, &rc)) { |
1411 | 1026 | HBRUSH hBrush = NULL; |
1412 | - if ((hBrush = CreateSolidBrush(dwBackColor & 0x00ffffff)) != NULL) { // 背景色を設定 | |
1027 | + if ((hBrush = CreateSolidBrush(dwBackColor & 0x00ffffff)) != NULL) { | |
1413 | 1028 | if (SelectObject(hDC, hBrush) != HGDI_ERROR) { |
1414 | 1029 | if (FillRect(hDC, &rc, hBrush) != 0) { |
1415 | 1030 | if (SetBkMode(hDC, TRANSPARENT) != 0) { |
1416 | 1031 | COLORREF dwColorPrev = 0; |
1417 | - if ((dwColorPrev = SetTextColor(hDC, dwTextColor & 0x00ffffff)) != CLR_INVALID) { // 文字色を設定 | |
1032 | + if ((dwColorPrev = SetTextColor(hDC, dwTextColor & 0x80ffffff)) != CLR_INVALID) { | |
1418 | 1033 | int iBkModePrev = 0; |
1419 | - if ((iBkModePrev = SetBkMode(hDC, TRANSPARENT)) != 0) { // 背景モードを設定 | |
1034 | + if ((iBkModePrev = SetBkMode(hDC, TRANSPARENT)) != 0) { | |
1420 | 1035 | if (lpszMode != NULL) { |
1421 | 1036 | HFONT hFont = NULL; |
1422 | 1037 | DWORD dwUnderline = 0; |
1423 | 1038 | if (GetKeyState(VK_CAPITAL) & 0x0001) dwUnderline = TRUE; else dwUnderline = FALSE; |
1424 | 1039 | #define FONT _T("Yu Gothic UI") |
1425 | 1040 | if ((hFont = CreateFont((rc.bottom - rc.top), (rc.right - rc.left) / 2, 0, 0, FW_BOLD, FALSE, dwUnderline, FALSE, |
1426 | - SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, | |
1427 | - PROOF_QUALITY, FIXED_PITCH, FONT)) != NULL) { | |
1041 | + SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, | |
1042 | + PROOF_QUALITY, FIXED_PITCH, FONT)) != NULL) { | |
1428 | 1043 | HFONT hFontPrev = NULL; |
1429 | 1044 | if ((hFontPrev = (HFONT)SelectObject(hDC, hFont)) != NULL) { |
1430 | 1045 | if (DrawTextEx(hDC, lpszMode, -1, &rc, DT_RIGHT | DT_SINGLELINE | DT_VCENTER, NULL) == 0) { |
@@ -1,15 +1,18 @@ | ||
1 | -// Cursor.h | |
1 | +// | |
2 | +// Cursor.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/12 JeffyTS New edit. | |
7 | +// #0000 2022/03/12 JeffyTS New edit. | |
8 | +// | |
7 | 9 | |
8 | 10 | // |
9 | 11 | // Include |
10 | 12 | // |
11 | 13 | #pragma once |
12 | 14 | #include "CommonDef.h" |
15 | +#include "Ime.h" | |
13 | 16 | #include "..\FlushMouseCursor\Resource.h" |
14 | 17 | #include "..\MiscLIB\CThread.h" |
15 | 18 |
@@ -18,17 +21,6 @@ | ||
18 | 21 | // |
19 | 22 | #define IMEMODECHAR 3 |
20 | 23 | |
21 | -// IME mode | |
22 | -#define IMECLOSE 0x0000 | |
23 | -#define IMEOPEN 0x0001 | |
24 | -#define IMEOFF (IME_CMODE_ALPHANUMERIC) // 0x00 : A 英数(直接入力) | |
25 | -#define HANEISU_IMEON (IME_CMODE_ROMAN | IME_CMODE_ALPHANUMERIC) // 0x10 :_A 半角英数 0001 0000 | |
26 | -#define HANKANA_IMEON (IME_CMODE_ROMAN | IME_CMODE_KATAKANA | IME_CMODE_NATIVE) // 0x13 :_カ 半角カナ 0001 0011 | |
27 | -#define ZENEISU_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE) // 0x18 :A 全角英数 0001 1000 | |
28 | -#define ZENHIRA_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE) // 0x19 :あ 全角ひら 0001 1001(漢字変換モード) | |
29 | -#define ZENKANA_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA | IME_CMODE_NATIVE) // 0x1B :カ 全角カナ 0001 1011 | |
30 | -#define IMEHIDE (0x88) // 0x88 :■ Hide 1001 1000 | |
31 | - | |
32 | 24 | #ifndef OCR_NORMAL |
33 | 25 | #define OCR_NORMAL 32512 // IDC_ARROW (WinUser.h) |
34 | 26 | #endif // !OCR_NORMAL |
@@ -49,14 +41,14 @@ | ||
49 | 41 | #define OCR_NO 32648 |
50 | 42 | #if(WINVER >= 0x0500) |
51 | 43 | #ifndef OCR_HAND |
52 | -#define OCR_HAND 32649 // IDC_HAND (WinUser.h) | |
44 | +#define OCR_HAND 32649 // IDC_HAND (WinUser.h) | |
53 | 45 | #endif // !OCR_HAND |
54 | 46 | #endif /* WINVER >= 0x0500 */ |
55 | 47 | #ifndef OCR_HELP |
56 | 48 | #if(WINVER >= 0x0400) |
57 | 49 | #define OCR_APPSTARTING 32650 |
58 | 50 | #endif /* WINVER >= 0x0400 */ |
59 | -#define OCR_HELP 32651 // IDC_HELP (WinUser.h) | |
51 | +#define OCR_HELP 32651 // IDC_HELP (WinUser.h) | |
60 | 52 | #endif // !OCR_HELP |
61 | 53 | #ifndef OCR_PIN |
62 | 54 | #define OCR_PIN 32671 // IDC_PIN (WinUser.h) |
@@ -64,70 +56,62 @@ | ||
64 | 56 | #ifndef OCR_PERSON |
65 | 57 | #define OCR_PERSON 32672 // IDC_PERSON (WinUser.h) |
66 | 58 | #endif // !OCR_PERSON |
67 | -#define OCR_HIDE 32896 // Hide Cursor | |
59 | +#define OCR_HIDE 32896 // Hide Cursor | |
68 | 60 | |
69 | 61 | // |
70 | 62 | // Struct Define |
71 | 63 | // |
72 | 64 | typedef struct tagMOUSECURSOR { |
73 | - DWORD id; // OCR_xxx | |
74 | - UINT uResourceID; // Resource ID | |
75 | - BOOL bReadReg; // TRUE = Read from Registry | |
76 | - TCHAR szRegValue[MAX_LOADSTRING]; // Registry Value | |
77 | - TCHAR szFile[_MAX_PATH]; // Cursor File Name | |
65 | + DWORD id; | |
66 | + UINT uResourceID; | |
67 | + BOOL bReadReg; | |
68 | + TCHAR szRegValue[MAX_LOADSTRING]; | |
69 | + TCHAR szFile[_MAX_PATH]; | |
78 | 70 | } MOUSECURSOR, * PMOUSECURSOR, * LPMOUSECURSOR; |
79 | 71 | |
80 | 72 | typedef struct tagFLUSHMOUSECURSOR { |
81 | - UINT dwIMEMode; // IME Mode ID | |
82 | - TCHAR szMode[IMEMODECHAR]; // Mode Display Char | |
83 | - MOUSECURSOR stArrow; // Arrow MOUSECURSOR | |
84 | - MOUSECURSOR stHand; // Hand MOUSECURSOR | |
85 | - MOUSECURSOR stIBeam; // IBeam MOUSECURSOR | |
73 | + DWORD dwIMEMode; | |
74 | + TCHAR szMode[IMEMODECHAR]; | |
75 | + MOUSECURSOR stArrow; | |
76 | + MOUSECURSOR stHand; | |
77 | + MOUSECURSOR stIBeam; | |
86 | 78 | } FLUSHMOUSECURSOR, * PFLUSHMOUSECURSOR, * LPFLUSHMOUSECURSOR; |
87 | 79 | |
88 | 80 | typedef struct tagIMECursorData |
89 | 81 | { |
90 | - // Use in Cursor | |
91 | - HWND hWndObserved; | |
82 | + HWND hWndObserved; | |
92 | 83 | DWORD dwIMEModeCursor; |
93 | - BOOL bDrawIMEModeWait; | |
84 | + //DWORD dwIMEModeCaret; | |
85 | + BOOL bDrawIMEModeWait; | |
94 | 86 | LPCTSTR lpszLoadDatName; |
95 | 87 | LPFLUSHMOUSECURSOR lpstFlushMouseCursor; |
96 | 88 | |
97 | - // Use in Cursor from Registry | |
98 | 89 | int iCursorSize; |
99 | 90 | int iModeSize; |
100 | 91 | DWORD dwInThreadSleepTime; |
101 | 92 | DWORD dwWaitWaveTime; |
102 | 93 | DWORD dwDisplayModeTime; |
103 | - BOOL bDisplayIMEModeOnCursor; | |
104 | - BOOL bForceHiragana; | |
105 | - BOOL bDrawNearCaret; | |
106 | - COLORREF dwNearDrawCaretColor; | |
107 | - COLORREF dwNearDrawMouseColor; | |
108 | - | |
109 | - BOOL bDenyChangedByApp; | |
110 | - BOOL bUseBigArrow; | |
111 | - BOOL bDisplayFocusWindowIME; | |
112 | - | |
113 | - // Work data for Caret | |
114 | - HWND hWnd; | |
115 | - RECT rcCaret; | |
94 | + BOOL bDisplayIMEModeOnCursor; | |
95 | + BOOL bForceHiragana; | |
96 | + BOOL bDrawNearCaret; | |
97 | + COLORREF dwNearDrawCaretColor; | |
98 | + COLORREF dwNearDrawMouseColor; | |
99 | + | |
100 | + BOOL bDenyChangedByApp; | |
101 | + BOOL bUseBigArrow; | |
102 | + BOOL bDisplayFocusWindowIME; | |
103 | + | |
104 | + HWND hWnd; | |
105 | + RECT rcCaret; | |
116 | 106 | } IMECURSORDATA, * PIMECURSORDATA, * LPIMECURSORDATA; |
117 | 107 | |
118 | -typedef struct tagVirtualDesktop | |
119 | -{ | |
120 | - RECT rcMonitorSize; | |
121 | - int iNumOfMonitors; | |
122 | -} VIRTUALDESKTOP, * PVIRTUALDESKTOP, * LPVIRTUALDESKTOP; | |
123 | - | |
124 | 108 | // |
125 | 109 | // Class CCursorWindow |
126 | 110 | // |
127 | 111 | class CCursorWindow |
128 | 112 | { |
129 | 113 | public: |
130 | - CCursorWindow(); | |
114 | + CCursorWindow(); | |
131 | 115 | ~CCursorWindow(); |
132 | 116 | |
133 | 117 | public: |
@@ -140,6 +124,7 @@ private: | ||
140 | 124 | HWND InitInstance(HINSTANCE hInstance, int nCmdShow); |
141 | 125 | static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
142 | 126 | LRESULT CALLBACK _WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
127 | + | |
143 | 128 | BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct); |
144 | 129 | void Cls_OnDestroy(HWND hWnd); |
145 | 130 | void Cls_OnPaint(HWND hWnd); |
@@ -147,45 +132,11 @@ private: | ||
147 | 132 | public: |
148 | 133 | |
149 | 134 | private: |
150 | - LPTSTR lpszWindowClass; | |
135 | + LPTSTR lpszWindowClass; | |
151 | 136 | HWND hCursorWindow; |
152 | - LPTSTR lpszMode; | |
137 | + LPTSTR lpszMode; | |
153 | 138 | COLORREF dwTextColor; |
154 | 139 | COLORREF dwBackColor; |
155 | - | |
156 | -}; | |
157 | - | |
158 | -// | |
159 | -// Class CIME | |
160 | -// | |
161 | -class CIME | |
162 | -{ | |
163 | -public: | |
164 | - CIME(); | |
165 | - ~CIME(); | |
166 | - | |
167 | -public: | |
168 | - BOOL bIsIMEOpen(HWND hWndObserved); | |
169 | - VOID vIMEOpenCloseForced(HWND hWndObserved, DWORD dwIMEOpenClose); | |
170 | - VOID vIMEConvertModeChangeForced(HWND hWndObserved, DWORD dwConvertMode); | |
171 | - DWORD dwIMEMode(HWND hWndObserved, BOOL bForceHiragana); | |
172 | - VOID vActivateIME(HWND hWndObserved); | |
173 | - BOOL bMoveIMEToolbar(); | |
174 | - BOOL bGetVirtualDesktopSize(); | |
175 | - BOOL bIsNewIME(); | |
176 | - DWORD dwGetInputLocale(); | |
177 | - HKL hklGetInputLocale(HWND hWndObserved); | |
178 | - | |
179 | -private: | |
180 | - BOOL bExistIMEToolbar(); | |
181 | - static BOOL bGetVirtualDesktopSizeEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam); | |
182 | - | |
183 | - static BOOL CALLBACK bEnumChildProcIMEOpenClose(HWND hWnd, LPARAM lParam); | |
184 | - static BOOL CALLBACK bEnumChildProcIMEConvertMode(HWND hWnd, LPARAM lParam); | |
185 | - static BOOL CALLBACK bEnumChildProcActivateIME(HWND hWnd, LPARAM lParam); | |
186 | - | |
187 | -private: | |
188 | - LPVIRTUALDESKTOP lpstVirtualDesktop; | |
189 | 140 | }; |
190 | 141 | |
191 | 142 | // |
@@ -202,15 +153,17 @@ public: | ||
202 | 153 | BOOL bStartIMECursorChangeThread(HWND hWndObserved); |
203 | 154 | BOOL bStartDrawIMEModeThread(HWND hWndObserved); |
204 | 155 | BOOL bStartDrawIMEModeThreadWait(HWND hWndObserved); |
156 | + BOOL bStartDrawIMEModeThreadWaitEventForeGround(HWND hWndObserved); | |
205 | 157 | BOOL bStartDrawIMEModeThreadWaitDblClk(HWND hWndObserved); |
158 | + | |
206 | 159 | BOOL bShowHideCursor(HWND hWndObserved, BOOL bShow); |
207 | 160 | BOOL bGetCaretPos(HWND hWnd, LPPOINT lpCaretPos); |
208 | 161 | |
209 | 162 | private: |
210 | 163 | BOOL _bStartDrawIMEModeThread(HWND hWndObserved); |
211 | 164 | |
212 | - LPTSTR lpszGetCursorDataName(); | |
213 | - HMODULE hCursorDllLoad(); | |
165 | + LPTSTR lpszGetCursorDataName(); | |
166 | + HMODULE hCursorDllLoad(); | |
214 | 167 | BOOL bCursorDllUnload(); |
215 | 168 | BOOL bSystemCursorLoad(); |
216 | 169 |
@@ -222,10 +175,9 @@ private: | ||
222 | 175 | BOOL bDrawIMEModeOnDisplay(LPIMECURSORDATA lpstCursorData); |
223 | 176 | BOOL _bCalcDispModeRect(int iModeSizeX, int iModeSizeY, LPRECT lpRect); |
224 | 177 | HWND _hGetCaretPosByAccessibleObjectFromWindow(HWND hForeWnd, LPRECT lprcCaret); |
225 | - HWND _hGetCaretPosByGuiThreadInfo(HWND hForeWnd, LPRECT lpRect); | |
226 | 178 | BOOL _bAdjustCaretByMonitorDPI(int iModeSizeX, int iModeSizeY, LPRECT lprcCaret); |
227 | 179 | BOOL bDrawIMEModeOnDisplaySub(LPIMECURSORDATA lpstCursorData); |
228 | - static BOOL bIconDrawEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam); | |
180 | + static BOOL bIconDrawEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam); | |
229 | 181 | static BOOL WINAPI bDrawIMEModeRoutine(LPVOID lpvParam); |
230 | 182 | |
231 | 183 | BOOL bGetMouseRegValue(LPCTSTR szValue, LPTSTR szFile); |
@@ -237,66 +189,66 @@ public: | ||
237 | 189 | private: |
238 | 190 | IMECURSORDATA stIMECursorData; |
239 | 191 | |
240 | - HWND hMainWnd; | |
192 | + HWND hMainWnd; | |
241 | 193 | HMODULE hModDll; |
242 | 194 | int iCursorDataLoadCount; |
243 | 195 | |
244 | - CThread* IMECursorChangeThread; | |
245 | - CThread* DrawIMEModeThread; | |
246 | - CThread* DrawIMEModeCaretThread; | |
247 | - CCursorWindow* CursorWindow; | |
248 | - CCursorWindow* CaretWindow; | |
249 | - | |
250 | - MOUSECURSOR stAllMouseCursor[sizeof(MOUSECURSOR) * 19] = { | |
251 | - { OCR_APPSTARTING, 0, TRUE, _T("AppStarting"), _T("") }, | |
252 | - { OCR_NORMAL, 0, FALSE, _T("Arrow"), _T("") }, | |
253 | - { OCR_CROSS, 0, TRUE, _T("Crosshair"), _T("") }, | |
254 | - { OCR_HAND, 0, FALSE, _T("Hand"), _T("") }, | |
255 | - { OCR_HELP, 0, TRUE, _T("Help"), _T("") }, | |
256 | - { OCR_IBEAM, 0, FALSE, _T("IBeam"), _T("") }, | |
257 | - { OCR_NO, 0, TRUE, _T("No"), _T("") }, | |
258 | - // { OCR_NWPEN, 0, TRUE, _T("NWPen"), _T("") }, | |
259 | - // { OCR_PEN, 0, TRUE, _T("Pen"), _T("") }, | |
260 | - { OCR_PERSON, 0, TRUE, _T("Person"), _T("") }, | |
261 | - { OCR_PIN, 0, TRUE, _T("Pin"), _T("") }, | |
262 | - { OCR_SIZEALL, 0, TRUE, _T("SizeAll"), _T("") }, | |
263 | - { OCR_SIZENESW, 0, TRUE, _T("SizeNESW"), _T("") }, | |
264 | - { OCR_SIZENS, 0, TRUE, _T("SizeNS"), _T("") }, | |
265 | - { OCR_SIZENWSE, 0, TRUE, _T("SizeNWSE"), _T("") }, | |
266 | - { OCR_SIZEWE, 0, TRUE, _T("SizeWE"), _T("") }, | |
267 | - { OCR_UP, 0, TRUE, _T("UpArrow"), _T("") }, | |
268 | - { OCR_WAIT, 0, TRUE, _T("Wait"), _T("") }, | |
269 | - { OCR_HIDE, 0, TRUE, _T("Hide"), _T("") }, | |
270 | - { (DWORD)(-1), 0, FALSE, _T(""), _T("") } // Terminater | |
196 | + CThread* IMECursorChangeThread; | |
197 | + CThread* DrawIMEModeThread; | |
198 | + CThread* DrawIMEModeCaretThread; | |
199 | + CCursorWindow* CursorWindow; | |
200 | + CCursorWindow* CaretWindow; | |
201 | + | |
202 | + MOUSECURSOR stAllMouseCursor[sizeof(MOUSECURSOR) * 20] = { | |
203 | + { OCR_APPSTARTING, 0, TRUE, _T("AppStarting"), _T("") }, | |
204 | + { OCR_NORMAL, 0, FALSE, _T("Arrow"), _T("") }, | |
205 | + { OCR_CROSS, 0, TRUE, _T("Crosshair"), _T("") }, | |
206 | + { OCR_HAND, 0, FALSE, _T("Hand"), _T("") }, | |
207 | + { OCR_HELP, 0, TRUE, _T("Help"), _T("") }, | |
208 | + { OCR_IBEAM, 0, FALSE, _T("IBeam"), _T("") }, | |
209 | + { OCR_NO, 0, TRUE, _T("No"), _T("") }, | |
210 | + // { OCR_NWPEN, 0, TRUE, _T("NWPen"), _T("") }, | |
211 | + // { OCR_PEN, 0, TRUE, _T("Pen"), _T("") }, | |
212 | + { OCR_PERSON, 0, TRUE, _T("Person"), _T("") }, | |
213 | + { OCR_PIN, 0, TRUE, _T("Pin"), _T("") }, | |
214 | + { OCR_SIZEALL, 0, TRUE, _T("SizeAll"), _T("") }, | |
215 | + { OCR_SIZENESW, 0, TRUE, _T("SizeNESW"), _T("") }, | |
216 | + { OCR_SIZENS, 0, TRUE, _T("SizeNS"), _T("") }, | |
217 | + { OCR_SIZENWSE, 0, TRUE, _T("SizeNWSE"), _T("") }, | |
218 | + { OCR_SIZEWE, 0, TRUE, _T("SizeWE"), _T("") }, | |
219 | + { OCR_UP, 0, TRUE, _T("UpArrow"), _T("") }, | |
220 | + { OCR_WAIT, 0, TRUE, _T("Wait"), _T("") }, | |
221 | + { OCR_HIDE, 0, TRUE, _T("Hide"), _T("") }, | |
222 | + { (DWORD)(-1), 0, FALSE, _T(""), _T("") } | |
271 | 223 | }; |
272 | 224 | |
273 | - FLUSHMOUSECURSOR stFlushMouseCursor[sizeof(FLUSHMOUSECURSOR) * 7] = { | |
274 | - { IMEOFF, _T("A"), {OCR_NORMAL, IDC_IMEOFF_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeOffArrow.cur")}, | |
225 | + FLUSHMOUSECURSOR stFlushMouseCursor[sizeof(FLUSHMOUSECURSOR) * 8] = { | |
226 | + { IMEOFF, _T("A"), {OCR_NORMAL, IDC_IMEOFF_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeOffArrow.cur")}, | |
275 | 227 | {OCR_HAND, IDC_IMEOFF_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeOffHand.cur")}, |
276 | 228 | {OCR_IBEAM, IDC_IMEOFF_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeOffIBeam.cur")}}, |
277 | - { ZENHIRA_IMEON, _T("あ"), {OCR_NORMAL, IDC_ZENHIRA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenHiraOnArrow.cur")}, | |
229 | + { ZENHIRA_IMEON, _T("あ"), {OCR_NORMAL, IDC_ZENHIRA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenHiraOnArrow.cur")}, | |
278 | 230 | {OCR_HAND, IDC_ZENHIRA_IMEON_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenHiraOnHand.cur")}, |
279 | 231 | {OCR_IBEAM, IDC_ZENHIRA_IMEON_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenHiraOnIBeam.cur")}}, |
280 | - { HANEISU_IMEON, _T("_A"), {OCR_NORMAL, IDC_HANEISU_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanEisuOnArrow.cur")}, | |
232 | + { HANEISU_IMEON, _T("_A"), {OCR_NORMAL, IDC_HANEISU_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanEisuOnArrow.cur")}, | |
281 | 233 | {OCR_HAND, IDC_HANEISU_IMEON_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanEisuOnHand.cur")}, |
282 | 234 | {OCR_IBEAM, IDC_HANEISU_IMEON_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanEisuOnIBeam.cur")}}, |
283 | - { HANKANA_IMEON, _T("_ア"), {OCR_NORMAL, IDC_HANKANA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanKanaOnArrow.cur")}, | |
235 | + { HANKANA_IMEON, _T("_ア"), {OCR_NORMAL, IDC_HANKANA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanKanaOnArrow.cur")}, | |
284 | 236 | {OCR_HAND, IDC_HANKANA_IMEON_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanKanaOnHand.cur")}, |
285 | 237 | {OCR_IBEAM, IDC_HANKANA_IMEON_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHanKanaOnIBeam.cur")}}, |
286 | - { ZENEISU_IMEON, _T("A"), {OCR_NORMAL, IDC_ZENEISU_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenEisuOnArrow.cur")}, | |
238 | + { ZENEISU_IMEON, _T("A"), {OCR_NORMAL, IDC_ZENEISU_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenEisuOnArrow.cur")}, | |
287 | 239 | {OCR_HAND, IDC_ZENEISU_IMEON_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenEisuOnHand.cur")}, |
288 | 240 | {OCR_IBEAM, IDC_ZENEISU_IMEON_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenEisuOnIBeam.cur")}}, |
289 | - { ZENKANA_IMEON, _T("ア"), {OCR_NORMAL, IDC_ZENKANA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenKanaOnArrow.cur")}, | |
241 | + { ZENKANA_IMEON, _T("ア"), {OCR_NORMAL, IDC_ZENKANA_IMEON_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenKanaOnArrow.cur")}, | |
290 | 242 | {OCR_HAND, IDC_ZENKANA_IMEON_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenKanaOnHand.cur")}, |
291 | 243 | {OCR_IBEAM, IDC_ZENKANA_IMEON_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeZenKanaOnIBeam.cur")}}, |
292 | 244 | { IMEHIDE, _T(""), {OCR_NORMAL, IDC_HIDE_ARROW, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHideOnArrow.cur")}, |
293 | 245 | {OCR_HAND, IDC_HIDE_HAND, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHideOnHand.cur")}, |
294 | 246 | {OCR_IBEAM, IDC_HIDE_IBEAM, FALSE, _T(""), _T("%APPDATA%\\JeffyTS\\FlushMouse\\ImeHideOnIBeam.cur")}}, |
295 | - { (DWORD)(-1), _T(""), {0, 0, FALSE, _T(""), _T("")}, // Terminater | |
296 | - {0, 0, FALSE, _T(""), _T("")}, // Terminater | |
297 | - {0, 0, FALSE, _T(""), _T("")} } // Terminater | |
247 | + { (DWORD)(-1), _T(""), {0, 0, FALSE, _T(""), _T("")}, | |
248 | + {0, 0, FALSE, _T(""), _T("")}, | |
249 | + {0, 0, FALSE, _T(""), _T("")} } | |
298 | 250 | }; |
299 | - | |
300 | 251 | }; |
301 | 252 | |
253 | + | |
302 | 254 | /* = EOF = */ |
\ No newline at end of file |
@@ -1,4 +1,5 @@ | ||
1 | -// FlushMouse.cpp | |
1 | +// | |
2 | +// FlushMouse.cpp | |
2 | 3 | // for Windows10/11 Win32 API msi Packaage App. |
3 | 4 | // Copyright (C) 1993 JeffyTS |
4 | 5 | // |
@@ -7,8 +8,8 @@ | ||
7 | 8 | // |
8 | 9 | // No. Date Name Reason & Document |
9 | 10 | // -------+-----------+-----------+-------------------------------------------- - |
10 | -// #0000 1993/11/17 JeffyTS New edit. | |
11 | -// #0001 2022/02/04 JeffyTS Visual Studio 2022 (C++)へ移植 | |
11 | +// #0000 1993/11/17 JeffyTS New edit. | |
12 | +// #0001 2022/02/04 JeffyTS Visual Studio 2022 (C++)へ移植 | |
12 | 13 | // |
13 | 14 | |
14 | 15 | // |
@@ -21,6 +22,7 @@ | ||
21 | 22 | #include "..\version.h" |
22 | 23 | #include "FlushMouseLIB.h" |
23 | 24 | #include "Resource.h" |
25 | +#include "TaskTray.h" | |
24 | 26 | #include "..\FlushMouseDLL\EventlogDll.h" |
25 | 27 | |
26 | 28 | #if defined _DEBUG |
@@ -41,8 +43,8 @@ | ||
41 | 43 | // Global Data |
42 | 44 | // |
43 | 45 | // Hook |
44 | -TCHAR szFlushMouse64[] = _T("FlushMouseDLL.dll"); | |
45 | -TCHAR szFlushMouse32[] = _T("FlushMouse32.exe"); | |
46 | +TCHAR szFlushMouseDLL[] = FLUSHMOUSE_DLL; | |
47 | +TCHAR szFlushMouse32[] = FLUSHMOUSE32_EXE; | |
46 | 48 | |
47 | 49 | // |
48 | 50 | // Local Data |
@@ -1,10 +1,11 @@ | ||
1 | -// FlushMouse.h | |
1 | +// | |
2 | +// FlushMouse.h | |
2 | 3 | // Copyright (C) 1993 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 1993/11/17 JeffyTS New edit. | |
7 | -// #0001 2022/02/04 JeffyTS Visual Studio 2022 (C++)へ移植 | |
7 | +// #0000 1993/11/17 JeffyTS New edit. | |
8 | +// #0001 2022/02/04 JeffyTS Visual Studio 2022 (C++)へ移植 | |
8 | 9 | // |
9 | 10 | |
10 | 11 | // |
@@ -23,5 +24,8 @@ | ||
23 | 24 | // |
24 | 25 | // Global Data |
25 | 26 | // |
27 | +extern TCHAR szFlushMouseDLL[]; | |
28 | +extern TCHAR szFlushMouse32[]; | |
29 | + | |
26 | 30 | |
27 | 31 | /* = EOF = */ |
\ No newline at end of file |
@@ -218,18 +218,22 @@ | ||
218 | 218 | <ClInclude Include="FlushMouseLIB.h" /> |
219 | 219 | <ClInclude Include="FlushMouseSub.h" /> |
220 | 220 | <ClInclude Include="framework.h" /> |
221 | + <ClInclude Include="Ime.h" /> | |
221 | 222 | <ClInclude Include="pch.h" /> |
222 | 223 | <ClInclude Include="Profile.h" /> |
223 | 224 | <ClInclude Include="Resource.h" /> |
224 | 225 | <ClInclude Include="targetver.h" /> |
226 | + <ClInclude Include="TaskTray.h" /> | |
225 | 227 | </ItemGroup> |
226 | 228 | <ItemGroup> |
227 | 229 | <ClCompile Include="FlushMouse.cpp" /> |
228 | 230 | <ClCompile Include="Cursor.cpp" /> |
229 | 231 | <ClCompile Include="FlushMouseLIB.cpp" /> |
230 | 232 | <ClCompile Include="FlushMouseSub.cpp" /> |
233 | + <ClCompile Include="Ime.cpp" /> | |
231 | 234 | <ClCompile Include="pch.cpp" /> |
232 | 235 | <ClCompile Include="Profile.cpp" /> |
236 | + <ClCompile Include="TaskTray.cpp" /> | |
233 | 237 | </ItemGroup> |
234 | 238 | <ItemGroup> |
235 | 239 | <ResourceCompile Include="FlushMouse.rc" /> |
@@ -45,6 +45,12 @@ | ||
45 | 45 | <ClInclude Include="CommonDef.h"> |
46 | 46 | <Filter>ヘッダー ファイル</Filter> |
47 | 47 | </ClInclude> |
48 | + <ClInclude Include="Ime.h"> | |
49 | + <Filter>ヘッダー ファイル</Filter> | |
50 | + </ClInclude> | |
51 | + <ClInclude Include="TaskTray.h"> | |
52 | + <Filter>ヘッダー ファイル</Filter> | |
53 | + </ClInclude> | |
48 | 54 | </ItemGroup> |
49 | 55 | <ItemGroup> |
50 | 56 | <ClCompile Include="FlushMouse.cpp"> |
@@ -65,6 +71,12 @@ | ||
65 | 71 | <ClCompile Include="FlushMouseLIB.cpp"> |
66 | 72 | <Filter>ソース ファイル</Filter> |
67 | 73 | </ClCompile> |
74 | + <ClCompile Include="Ime.cpp"> | |
75 | + <Filter>ソース ファイル</Filter> | |
76 | + </ClCompile> | |
77 | + <ClCompile Include="TaskTray.cpp"> | |
78 | + <Filter>ソース ファイル</Filter> | |
79 | + </ClCompile> | |
68 | 80 | </ItemGroup> |
69 | 81 | <ItemGroup> |
70 | 82 | <ResourceCompile Include="FlushMouse.rc"> |
@@ -1,9 +1,10 @@ | ||
1 | +// | |
1 | 2 | // FlushMouseLIB.cpp |
2 | 3 | // Copyright (C) 1993 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/07/09 JeffyTS New edit. | |
7 | +// #0000 2022/07/09 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -14,6 +15,7 @@ | ||
14 | 15 | #include "FlushMouseLIB.h" |
15 | 16 | #include "FlushMouseSub.h" |
16 | 17 | #include "Cursor.h" |
18 | +#include "TaskTray.h" | |
17 | 19 | #include "Profile.h" |
18 | 20 | #include "Resource.h" |
19 | 21 | #include "CommonDef.h" |
@@ -36,13 +38,13 @@ | ||
36 | 38 | // Global Data |
37 | 39 | // |
38 | 40 | // Hook |
39 | -TCHAR szTitle[MAX_LOADSTRING]{}; // タイトル バーのテキスト | |
41 | +TCHAR szTitle[MAX_LOADSTRING]{}; | |
40 | 42 | HWND hMainWnd = NULL; |
41 | 43 | |
42 | -CProfile * Profile = NULL; // Profile class | |
43 | -CCursor * Cursor = NULL; // Cursor class | |
44 | -CResource * Resource = NULL; // Resource class | |
45 | -CIME * Cime = NULL; // IME class | |
44 | +CProfile *Profile = NULL; | |
45 | +CCursor *Cursor = NULL; | |
46 | +CResource *Resource = NULL; | |
47 | +CIME *Cime = NULL; | |
46 | 48 | |
47 | 49 | // Use in FlushMouse from Registry |
48 | 50 | BOOL bDisplayIMEModeOnCursor = TRUE; |
@@ -62,24 +64,24 @@ BOOL bIMEModeForced = FALSE; | ||
62 | 64 | // Timer for Cursor |
63 | 65 | #define FOCUSINITTIMERVALUE 200 |
64 | 66 | #define CHECKFOCUSTIMERID 1 |
65 | -static UINT nCheckFocusTimerTickValue = FOCUSINITTIMERVALUE; // Timer tick | |
66 | -static UINT_PTR nCheckFocusTimerID = CHECKFOCUSTIMERID; // Timer ID | |
67 | +static UINT nCheckFocusTimerTickValue = FOCUSINITTIMERVALUE; | |
68 | +static UINT_PTR nCheckFocusTimerID = CHECKFOCUSTIMERID; | |
67 | 69 | static UINT_PTR uCheckFocusTimer = NULL; |
68 | 70 | // Timer for Poc |
69 | 71 | #define PROCINITTIMERVALUE 1000 |
70 | 72 | #define CHECKPROCTIMERID 2 |
71 | -static UINT nCheckProcTimerTickValue = PROCINITTIMERVALUE; // Timer tick | |
72 | -static UINT_PTR nCheckProcTimerID = CHECKPROCTIMERID; // Timer ID | |
73 | +static UINT nCheckProcTimerTickValue = PROCINITTIMERVALUE; | |
74 | +static UINT_PTR nCheckProcTimerID = CHECKPROCTIMERID; | |
73 | 75 | static UINT_PTR uCheckProcTimer = NULL; |
74 | 76 | |
75 | 77 | // Hook |
76 | -static CFlushMouseHook* FlushMouseHook = NULL; | |
78 | +static CFlushMouseHook *FlushMouseHook = NULL; | |
77 | 79 | |
78 | -// Event Handler | |
79 | -static CEventHook* EventHook = NULL; | |
80 | +// Event Handler | |
81 | +static CEventHook *EventHook = NULL; | |
80 | 82 | |
81 | 83 | // for PowerNotification |
82 | -static CPowerNotification* PowerNotification = NULL; | |
84 | +static CPowerNotification *PowerNotification = NULL; | |
83 | 85 | |
84 | 86 | // |
85 | 87 | // Global Prototype Define |
@@ -115,9 +117,9 @@ static void Cls_OnCheckExistingJPIMEEx(HWND hWnd, BOOL bEPHelper); | ||
115 | 117 | static BOOL bSendInputSub(UINT cInputs, LPINPUT pInputs); |
116 | 118 | static BOOL bKBisEP(); |
117 | 119 | static BOOL bChangeHKLbySendInput(HKL hNewHKL, HKL hPreviousHKL); |
118 | -static VOID CALLBACK vCheckFocusTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DWORD dwTime); | |
119 | -static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DWORD dwTime); | |
120 | -static BOOL CALLBACK bEnumChildProcChangeHKL(HWND hWnd, LPARAM lParam); | |
120 | +static VOID CALLBACK vCheckFocusTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DWORD dwTime); | |
121 | +static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DWORD dwTime); | |
122 | +static BOOL CALLBACK bEnumChildProcChangeHKL(HWND hWnd, LPARAM lParam); | |
121 | 123 | |
122 | 124 | // |
123 | 125 | // bWinMain() |
@@ -263,6 +265,9 @@ static BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) | ||
263 | 265 | { |
264 | 266 | UNREFERENCED_PARAMETER(lpCreateStruct); |
265 | 267 | #define MessageBoxTYPE (MB_ICONSTOP | MB_OK) |
268 | + | |
269 | + hMainWnd = hWnd; | |
270 | + | |
266 | 271 | Cime = new CIME; |
267 | 272 | |
268 | 273 | Profile = new CProfile; |
@@ -274,7 +279,6 @@ static BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) | ||
274 | 279 | |
275 | 280 | vGetSetProfileData(); |
276 | 281 | |
277 | - // Create Task Tray | |
278 | 282 | HICON hIcon = NULL; |
279 | 283 | if ((hIcon = LoadIcon(Resource->hLoad(), MAKEINTRESOURCE(IDI_FLUSHMOUSE))) != NULL) { |
280 | 284 | if (bCreateTaskTrayWindow(hWnd, hIcon, szTitle) == FALSE) { |
@@ -293,7 +297,6 @@ static BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) | ||
293 | 297 | return FALSE; |
294 | 298 | } |
295 | 299 | |
296 | - // for PowerNotification | |
297 | 300 | PowerNotification = new CPowerNotification(hWnd); |
298 | 301 | if (!PowerNotification) { |
299 | 302 | vMessageBox(hWnd, IDS_NOTRREGISTEVH, MessageBoxTYPE); |
@@ -321,7 +324,14 @@ static BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) | ||
321 | 324 | // |
322 | 325 | static void Cls_OnDestroy(HWND hWnd) |
323 | 326 | { |
327 | + vDestroyWindow(hWnd); | |
328 | +} | |
324 | 329 | |
330 | +// | |
331 | +// vDestroyWindow() | |
332 | +// | |
333 | +void vDestroyWindow(HWND hWnd) | |
334 | +{ | |
325 | 335 | vStopThreadHookTimer(hWnd); |
326 | 336 | |
327 | 337 | SystemParametersInfo(SPI_SETCURSORS, 0, NULL, 0); |
@@ -340,12 +350,6 @@ static void Cls_OnDestroy(HWND hWnd) | ||
340 | 350 | PowerNotification = NULL; |
341 | 351 | } |
342 | 352 | |
343 | - if (Resource != NULL) { | |
344 | - Resource->bUnload(); | |
345 | - delete Resource; | |
346 | - Resource = NULL; | |
347 | - } | |
348 | - | |
349 | 353 | if (Cime != NULL) { |
350 | 354 | delete Cime; |
351 | 355 | Cime = NULL; |
@@ -443,15 +447,11 @@ static void Cls_OnLButtonUpEx(HWND hWnd, int x, int y, HWND hForeground) | ||
443 | 447 | UNREFERENCED_PARAMETER(x); |
444 | 448 | UNREFERENCED_PARAMETER(y); |
445 | 449 | UNREFERENCED_PARAMETER(hForeground); |
446 | - if (bMoveIMEToolbar && (GetAsyncKeyState(VK_MENU) & 0x8000) && (GetAsyncKeyState(VK_CONTROL) & 0x8000)) { | |
447 | - if (!Cime->bMoveIMEToolbar()) { | |
448 | - } | |
449 | - } | |
450 | 450 | if (bDoModeDispByMouseBttnUp) { |
451 | 451 | HWND hWndObserved = NULL; |
452 | 452 | POINT pt{}; |
453 | 453 | if (GetCursorPos(&pt)) { |
454 | - RECT rc{}; | |
454 | + RECT rc{}; | |
455 | 455 | if ((hWndObserved = WindowFromPoint(pt)) == NULL) return; |
456 | 456 | if (FindWindow(L"Shell_TrayWnd", NULL) == GetForegroundWindow()) { |
457 | 457 | if (bGetTaskTrayWindowRect(hWnd, &rc) == FALSE) return; |
@@ -482,12 +482,12 @@ static void Cls_OnEventForegroundEx(HWND hWnd, DWORD dwEvent, HWND hForeWnd) | ||
482 | 482 | if (EventHook->hFormerWnd != hForeWnd) { |
483 | 483 | EventHook->hFormerWnd = hForeWnd; |
484 | 484 | if (hWnd != hForeWnd) { |
485 | - HWND hWndObserved = NULL; | |
485 | + HWND hWndObserved = NULL; | |
486 | + POINT pt{}; | |
486 | 487 | if (bDisplayFocusWindowIME) { |
487 | - hWndObserved = hWnd; | |
488 | + hWndObserved = hForeWnd; | |
488 | 489 | } |
489 | 490 | else { |
490 | - POINT pt{}; | |
491 | 491 | if (GetCursorPos(&pt)) { |
492 | 492 | if ((hWndObserved = WindowFromPoint(pt)) == NULL) return; |
493 | 493 | } |
@@ -502,14 +502,13 @@ static void Cls_OnEventForegroundEx(HWND hWnd, DWORD dwEvent, HWND hForeWnd) | ||
502 | 502 | Cime->vIMEOpenCloseForced(hForeWnd, IMECLOSE); |
503 | 503 | } |
504 | 504 | if (!Cursor->bStartIMECursorChangeThread(hWndObserved)) return; |
505 | - POINT pt{}; | |
506 | 505 | if (GetCursorPos(&pt)) { |
507 | - RECT rc{}; | |
508 | - if (FindWindow(L"Shell_TrayWnd", NULL) == GetForegroundWindow()) { | |
506 | + RECT rc{}; | |
507 | + if (FindWindow(L"Shell_TrayWnd", NULL) == hForeWnd) { | |
509 | 508 | if (bGetTaskTrayWindowRect(hWnd, &rc) == FALSE) return; |
510 | 509 | if (((pt.x >= rc.left) && (pt.x <= rc.right)) || ((pt.y <= rc.top) && (pt.y >= rc.bottom))) return; |
511 | 510 | } |
512 | - if (!Cursor->bStartDrawIMEModeThreadWait(hForeWnd)) return; | |
511 | + if (!Cursor->bStartDrawIMEModeThreadWaitEventForeGround(hForeWnd)) return; | |
513 | 512 | } |
514 | 513 | } |
515 | 514 | } |
@@ -524,7 +523,7 @@ static void Cls_OnCheckIMEStartConvertingEx(HWND hWnd, BOOL bStartConverting, D | ||
524 | 523 | UNREFERENCED_PARAMETER(hWnd); |
525 | 524 | UNREFERENCED_PARAMETER(vkCode); |
526 | 525 | |
527 | - HWND hWndObserved = GetForegroundWindow(); | |
526 | + HWND hWndObserved = GetForegroundWindow(); | |
528 | 527 | POINT pt{}; |
529 | 528 | if (Cursor->bGetCaretPos(hWndObserved, &pt)) { |
530 | 529 | if ((pt.x != 0) && (pt.y != 0)) { |
@@ -532,7 +531,7 @@ static void Cls_OnCheckIMEStartConvertingEx(HWND hWnd, BOOL bStartConverting, D | ||
532 | 531 | } |
533 | 532 | } |
534 | 533 | if (Cime->dwIMEMode(hWndObserved, FALSE) != IMEOFF) bIMEInConverting = bStartConverting; |
535 | - else bIMEInConverting = FALSE; | |
534 | + else bIMEInConverting = FALSE; | |
536 | 535 | } |
537 | 536 | |
538 | 537 | // |
@@ -822,7 +821,7 @@ void Cls_OnCheckExistingJPIMEEx(HWND hWnd, BOOL bEPHelper) | ||
822 | 821 | // |
823 | 822 | static BOOL bKBisEP() |
824 | 823 | { |
825 | - if (GetKeyboardType(1) == 0) { // EP Keyboard | |
824 | + if (GetKeyboardType(1) == 0) { | |
826 | 825 | _Post_equals_last_error_ DWORD err = GetLastError(); |
827 | 826 | if (err != 0) { |
828 | 827 | } |
@@ -831,21 +830,19 @@ static BOOL bKBisEP() | ||
831 | 830 | } |
832 | 831 | } |
833 | 832 | |
834 | - // 2nd Check | |
835 | 833 | DWORD dProcessID = 0; |
836 | 834 | DWORD dThreadID = GetWindowThreadProcessId(GetForegroundWindow(), &dProcessID); |
837 | 835 | if (dThreadID != 0) { |
838 | 836 | HKL hkl = GetKeyboardLayout(dThreadID); |
839 | - if (hkl == US_ENG) { // EP Keyboard | |
837 | + if (hkl == US_ENG) { | |
840 | 838 | return TRUE; |
841 | 839 | } |
842 | 840 | } |
843 | 841 | |
844 | - // 3rd Check | |
845 | 842 | #define SUBKEY _T("SOFTWARE\\Microsoft\\Input\\Locales") |
846 | 843 | #define VALUE _T("InputLocale") |
847 | - DWORD dwInputLocale = 0; | |
848 | - CRegistry* CReg = new CRegistry; | |
844 | + DWORD dwInputLocale = 0; | |
845 | + CRegistry *CReg = new CRegistry; | |
849 | 846 | if (CReg) { |
850 | 847 | if (!CReg->bReadSystemRegValueDWORD(HKEY_LOCAL_MACHINE, SUBKEY, VALUE, &dwInputLocale)) { |
851 | 848 | } |
@@ -864,7 +861,7 @@ static BOOL bKBisEP() | ||
864 | 861 | BOOL bForExplorerPatcherSWS(HWND hForeWnd, BOOL bChangeToIME, BOOL bIMEModeForcedChange, LPHKL lpNewHKL, LPHKL lpPreviousHKL) |
865 | 862 | { |
866 | 863 | if (hForeWnd == NULL) return FALSE; |
867 | - BOOL bRet = FALSE; | |
864 | + BOOL bRet = FALSE; | |
868 | 865 | HKL hkl = NULL; |
869 | 866 | HKL hPreviousHKL = NULL; |
870 | 867 | DWORD dwProcessID = 0; |
@@ -912,7 +909,7 @@ BOOL bForExplorerPatcherSWS(HWND hForeWnd, BOOL bChangeToIME, BOOL bIMEModeForc | ||
912 | 909 | // |
913 | 910 | BOOL bChangeHKLbySendInput(HKL hNewHKL, HKL hPreviousHKL) |
914 | 911 | { |
915 | - BOOL bRet = FALSE; | |
912 | + BOOL bRet = FALSE; | |
916 | 913 | int iKBList = 0; |
917 | 914 | if ((iKBList = GetKeyboardLayoutList(0, NULL)) != 0) { |
918 | 915 | LPHKL lpHKL = NULL; |
@@ -960,7 +957,7 @@ BOOL bChangeHKLbySendInput(HKL hNewHKL, HKL hPreviousHKL) | ||
960 | 957 | // |
961 | 958 | BOOL CALLBACK bEnumChildProcChangeHKL(HWND hWnd, LPARAM lParam) |
962 | 959 | { |
963 | - HWND hIMWnd = NULL; | |
960 | + HWND hIMWnd = NULL; | |
964 | 961 | if (ActivateKeyboardLayout((HKL)lParam, KLF_SETFORPROCESS) != 0) { |
965 | 962 | if ((hIMWnd = ImmGetDefaultIMEWnd(hWnd)) != NULL) { |
966 | 963 | SendMessage(hIMWnd, WM_INPUTLANGCHANGEREQUEST, (WPARAM)INPUTLANGCHANGE_SYSCHARSET, lParam); |
@@ -974,7 +971,7 @@ BOOL CALLBACK bEnumChildProcChangeHKL(HWND hWnd, LPARAM lParam) | ||
974 | 971 | // |
975 | 972 | BOOL bCheckExistingJPIME() |
976 | 973 | { |
977 | - BOOL bRet = FALSE; | |
974 | + BOOL bRet = FALSE; | |
978 | 975 | LPHKL lpHKL = NULL; |
979 | 976 | int iKBList = 0; |
980 | 977 | if ((iKBList = GetKeyboardLayoutList(0, NULL)) != 0) { |
@@ -991,8 +988,15 @@ BOOL bCheckExistingJPIME() | ||
991 | 988 | if (lpHKL) delete[] lpHKL; |
992 | 989 | } |
993 | 990 | } |
994 | - HWND hWnd = FindWindow(CLASS_FLUSHMOUSE, NULL); | |
995 | - if (hWnd != NULL) PostMessage(hWnd, WM_CHECKEXISTINGJPIMEEX, (WPARAM)bRet, (LPARAM)NULL); | |
991 | + HWND hWnd = FindWindow(CLASS_FLUSHMOUSE, NULL); | |
992 | + if (hWnd != NULL) { | |
993 | + if (bEnableEPHelper) { | |
994 | + PostMessage(hWnd, WM_CHECKEXISTINGJPIMEEX, (WPARAM)bRet, (LPARAM)NULL); | |
995 | + } | |
996 | + else { | |
997 | + PostMessage(hWnd, WM_CHECKEXISTINGJPIMEEX, (WPARAM)FALSE, (LPARAM)NULL); | |
998 | + } | |
999 | + } | |
996 | 1000 | return bRet; |
997 | 1001 | } |
998 | 1002 |
@@ -1030,7 +1034,7 @@ BOOL bStartThreadHookTimer(HWND hWnd) | ||
1030 | 1034 | // Register Hook |
1031 | 1035 | if (FlushMouseHook == NULL) { |
1032 | 1036 | FlushMouseHook = new CFlushMouseHook; |
1033 | - if (!FlushMouseHook->bHookSet(hWnd, szFlushMouse64, szFlushMouse32)) { | |
1037 | + if (!FlushMouseHook->bHookSet(hWnd, szFlushMouseDLL, szFlushMouse32)) { | |
1034 | 1038 | vMessageBox(hWnd, IDS_NOTREGISTERHOOK, MessageBoxTYPE); |
1035 | 1039 | PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); |
1036 | 1040 | return FALSE; |
@@ -1038,7 +1042,7 @@ BOOL bStartThreadHookTimer(HWND hWnd) | ||
1038 | 1042 | } |
1039 | 1043 | |
1040 | 1044 | // Set Timer |
1041 | - BOOL bBool = FALSE; | |
1045 | + BOOL bBool = FALSE; | |
1042 | 1046 | if (SetUserObjectInformation(GetCurrentProcess(), UOI_TIMERPROC_EXCEPTION_SUPPRESSION, &bBool, sizeof(BOOL)) != FALSE) { |
1043 | 1047 | // Set Timer for Cursor |
1044 | 1048 | if (uCheckFocusTimer == NULL) { |
@@ -1159,14 +1163,39 @@ static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DW | ||
1159 | 1163 | |
1160 | 1164 | if (uTimerID == nCheckProcTimerID) { |
1161 | 1165 | if (FindWindow(CLASS_FLUSHMOUSE32, NULL) == NULL) { |
1166 | + vDestroyWindow(hWnd); | |
1162 | 1167 | bReportEvent(MSG_DETECT_FLUSHMOUSE_STOP, APPLICATION_CATEGORY); |
1168 | + bCreateProcess(FLUSHMOUSE_EXE); | |
1163 | 1169 | bReportEvent(MSG_RESTART_EVENT, APPLICATION_CATEGORY); |
1164 | - PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
1165 | 1170 | } |
1166 | 1171 | } |
1167 | 1172 | } |
1168 | 1173 | |
1169 | 1174 | // |
1175 | +// bCreateProcess() | |
1176 | +// | |
1177 | +BOOL bCreateProcess(LPCTSTR lpszExecName) | |
1178 | +{ | |
1179 | + BOOL bRet = FALSE; | |
1180 | + DWORD dwSize = 0; | |
1181 | + dwSize = ExpandEnvironmentStrings(lpszExecName, NULL, 0); | |
1182 | + LPTSTR lpszBuffer = new TCHAR[dwSize]; | |
1183 | + if (lpszBuffer) { | |
1184 | + ZeroMemory(lpszBuffer, dwSize); | |
1185 | + dwSize = ExpandEnvironmentStrings(lpszExecName, lpszBuffer, dwSize); | |
1186 | + PROCESS_INFORMATION ProcessInfomation{}; | |
1187 | + STARTUPINFO StartupInfo{}; StartupInfo.cb = sizeof(STARTUPINFO); | |
1188 | + if (CreateProcess(lpszBuffer, NULL, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &StartupInfo, &ProcessInfomation) != FALSE) { | |
1189 | + CloseHandle(ProcessInfomation.hProcess); | |
1190 | + CloseHandle(ProcessInfomation.hThread); | |
1191 | + bRet = TRUE; | |
1192 | + } | |
1193 | + delete[] lpszBuffer; | |
1194 | + } | |
1195 | + return bRet; | |
1196 | +} | |
1197 | + | |
1198 | +// | |
1170 | 1199 | // Class CResource |
1171 | 1200 | // |
1172 | 1201 | CResource::CResource() |
@@ -32,7 +32,7 @@ private: | ||
32 | 32 | |
33 | 33 | public: |
34 | 34 | HMODULE hLoad(); |
35 | - BOOL bUnload(); | |
35 | + BOOL bUnload(); | |
36 | 36 | |
37 | 37 | private: |
38 | 38 | LPTSTR szResFile; |
@@ -45,18 +45,20 @@ private: | ||
45 | 45 | // Global Prototype Define |
46 | 46 | // |
47 | 47 | extern BOOL bWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance); |
48 | +extern VOID vDestroyWindow(HWND hWnd); | |
48 | 49 | extern BOOL bStartThreadHookTimer(HWND hWnd); |
49 | 50 | extern VOID vStopThreadHookTimer(HWND hWnd); |
51 | +extern BOOL bCreateProcess(LPCTSTR lpszExecName); | |
50 | 52 | extern BOOL bForExplorerPatcherSWS(HWND hForeWnd, BOOL bChangeToIME, BOOL bIMEModeForcedChange, LPHKL lpNewHKL, LPHKL lpPreviousHKL); |
51 | 53 | extern BOOL bCheckExistingJPIME(); |
52 | 54 | |
53 | 55 | // |
54 | 56 | // Global Data |
55 | 57 | // |
56 | -extern TCHAR szFlushMouse64[]; | |
57 | -extern TCHAR szFlushMouse32[]; | |
58 | +extern TCHAR szFlushMouseDLL[]; | |
59 | +extern TCHAR szFlushMouse32[]; | |
58 | 60 | |
59 | -extern TCHAR szTitle[]; | |
61 | +extern TCHAR szTitle[]; | |
60 | 62 | extern HWND hMainWnd; |
61 | 63 | |
62 | 64 | extern BOOL bOffChangedFocus; |
@@ -72,7 +74,7 @@ extern BOOL bIMEModeForced; | ||
72 | 74 | |
73 | 75 | extern CProfile *Profile; |
74 | 76 | extern CCursor *Cursor; |
75 | -extern CResource *Resource; | |
77 | +extern CResource *Resource; | |
76 | 78 | extern CIME *Cime; |
77 | 79 | |
78 | 80 | /* = EOF = */ |
\ No newline at end of file |
@@ -11,11 +11,10 @@ | ||
11 | 11 | // |
12 | 12 | #pragma once |
13 | 13 | #include "pch.h" |
14 | -#include "FlushMouseLIB.h" | |
15 | 14 | #include "FlushMouseSub.h" |
15 | +#include "FlushMouseLIB.h" | |
16 | +#include "TaskTray.h" | |
16 | 17 | #include "CommonDef.h" |
17 | -#include "Profile.h" | |
18 | -#include "Resource.h" | |
19 | 18 | #include "..\FlushMouseDLL\GlobalHookDll.h" |
20 | 19 | #include "..\FlushMouseDLL\KeyboardHookDll.h" |
21 | 20 | #include "..\FlushMouseDLL\EventlogDll.h" |
@@ -29,501 +28,14 @@ | ||
29 | 28 | // |
30 | 29 | // Global Data |
31 | 30 | // |
32 | -HWND hAboutDlg = NULL; | |
33 | -HWND hSettingDlg = NULL; | |
34 | -BOOL bIMEInConverting = FALSE; | |
35 | 31 | |
36 | 32 | // |
37 | 33 | // Local Data |
38 | 34 | // |
39 | -static BOOL bTaskTray = FALSE; | |
40 | -static UINT uTaskbarCreatedMessage = 0; | |
41 | 35 | |
42 | 36 | // |
43 | 37 | // Local Prototype Define |
44 | 38 | // |
45 | -static INT_PTR CALLBACK SettingDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); | |
46 | -static BOOL bInitDlgCenter(HWND hDlg, HICON hIcon, DWORD dwICC); | |
47 | -static BOOL bSetCheckDlgButton(HWND hDlg, int iIDButton, BOOL bCheck); | |
48 | -static VOID vSetTrackbar(HWND hDlg, int iIDTrackbar, int iRangeMin, int iRangeMax, int iTickFreq, int iPos, int iPageSize); | |
49 | -static BOOL bGetDlgButtonChecked(HWND hDlg, int iIDButton); | |
50 | -static DWORD dwGetTrackbarPos(HWND hDlg, int iIDTrackbar); | |
51 | - | |
52 | -// | |
53 | -// bCreateTaskTrayWindow() | |
54 | -// | |
55 | -BOOL bCreateTaskTrayWindow(HWND hWnd, HICON hIcon, LPCTSTR lpszTitle) | |
56 | -{ | |
57 | - NOTIFYICONDATA nIco{}; | |
58 | - nIco.cbSize = sizeof(NOTIFYICONDATA); | |
59 | - nIco.hWnd = hWnd; | |
60 | - nIco.uID = NOTIFYICONDATA_ID; | |
61 | - nIco.guidItem = GUID_NULL; | |
62 | - nIco.uFlags = NIF_INFO | NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
63 | - nIco.uCallbackMessage = WM_TASKTRAYEX; | |
64 | - nIco.dwState = NIS_HIDDEN | NIS_SHAREDICON; | |
65 | - nIco.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON | NIIF_NOSOUND; | |
66 | - nIco.uVersion = NOTIFYICON_VERSION_4; | |
67 | - nIco.hIcon = hIcon; | |
68 | - if ((nIco.hIcon = LoadIcon(Resource->hLoad(), MAKEINTRESOURCE(IDI_FLUSHMOUSE))) == NULL) { | |
69 | - return FALSE; | |
70 | - } | |
71 | - _tcsncpy_s(nIco.szTip, ARRAYSIZE(nIco.szTip), lpszTitle, _TRUNCATE); | |
72 | - BOOL bRet = FALSE; | |
73 | - try { | |
74 | - throw bRet = Shell_NotifyIcon(NIM_ADD, &nIco); | |
75 | - } | |
76 | - catch (BOOL) { | |
77 | - if (!bRet) { | |
78 | - _Post_equals_last_error_ DWORD err = GetLastError(); | |
79 | - if (err == ERROR_TIMEOUT) { | |
80 | - Sleep(1000); | |
81 | - try { | |
82 | - throw bRet = Shell_NotifyIcon(NIM_ADD, &nIco); | |
83 | - } | |
84 | - catch (BOOL) { | |
85 | - if (!bRet) { | |
86 | - return FALSE; | |
87 | - } | |
88 | - } | |
89 | - catch (...) { | |
90 | - return FALSE; | |
91 | - } | |
92 | - } | |
93 | - else { | |
94 | - return FALSE; | |
95 | - } | |
96 | - } | |
97 | - } | |
98 | - catch (...) { | |
99 | - return FALSE; | |
100 | - } | |
101 | - | |
102 | - if ((uTaskbarCreatedMessage = RegisterWindowMessage(_T("TaskbarCreated"))) == 0) { | |
103 | - bDestroyTaskTrayWindow(hWnd); | |
104 | - return FALSE; | |
105 | - } | |
106 | - bTaskTray = TRUE; | |
107 | - return TRUE; | |
108 | -} | |
109 | - | |
110 | -// | |
111 | -// bReCreateTaskTrayWindow() | |
112 | -// | |
113 | -BOOL bReCreateTaskTrayWindow(HWND hWnd, UINT message) | |
114 | -{ | |
115 | - if (message == uTaskbarCreatedMessage) { | |
116 | - if (bDestroyTaskTrayWindow(hWnd)) { | |
117 | - bTaskTray = FALSE; | |
118 | - } | |
119 | - HICON hIcon = NULL; | |
120 | - if ((hIcon = LoadIcon(Resource->hLoad(), MAKEINTRESOURCE(IDI_FLUSHMOUSE))) != NULL) { | |
121 | - if (bCreateTaskTrayWindow(hWnd, hIcon, szTitle) == FALSE) { | |
122 | - bTaskTray = TRUE; | |
123 | - vStopThreadHookTimer(hWnd); | |
124 | - if (!bStartThreadHookTimer(hWnd)) { | |
125 | - bReportEvent(MSG_THREAD_HOOK_TIMER_RESTART_FAILED, APPLICATION_CATEGORY);// Eventlog | |
126 | - PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
127 | - } | |
128 | - bReportEvent(MSG_THREAD_HOOK_TIMER_RESTARTED, APPLICATION_CATEGORY); | |
129 | - return TRUE; | |
130 | - } | |
131 | - else { | |
132 | - if (bDestroyTaskTrayWindow(hWnd)) { | |
133 | - bTaskTray = FALSE; | |
134 | - } | |
135 | - bReportEvent(MSG_TASKTRAY_REGISTER_FAILD, APPLICATION_CATEGORY);// Eventlog | |
136 | - bReportEvent(MSG_RESTART_EVENT, APPLICATION_CATEGORY); | |
137 | - return TRUE; | |
138 | - } | |
139 | - } | |
140 | - else { | |
141 | - return FALSE; | |
142 | - } | |
143 | - } | |
144 | - return TRUE; | |
145 | -} | |
146 | - | |
147 | -// | |
148 | -// bDestroyTaskTrayWindow() | |
149 | -// | |
150 | -BOOL bDestroyTaskTrayWindow(HWND hWnd) | |
151 | -{ | |
152 | - if (bTaskTray != FALSE) { | |
153 | - NOTIFYICONDATA nIco{}; | |
154 | - nIco.cbSize = sizeof(NOTIFYICONDATA); | |
155 | - nIco.hWnd = hWnd; | |
156 | - nIco.uID = NOTIFYICONDATA_ID; | |
157 | - nIco.guidItem = GUID_NULL; | |
158 | - nIco.uFlags = 0; | |
159 | - try { | |
160 | - throw Shell_NotifyIcon(NIM_DELETE, &nIco); | |
161 | - } | |
162 | - catch (BOOL bRet) { | |
163 | - if (bRet) { | |
164 | - bTaskTray = FALSE; | |
165 | - return TRUE; | |
166 | - } | |
167 | - else { | |
168 | - return FALSE; | |
169 | - } | |
170 | - } | |
171 | - catch (...) { | |
172 | - return FALSE; | |
173 | - } | |
174 | - } | |
175 | - return TRUE; | |
176 | -} | |
177 | - | |
178 | -// | |
179 | -// bGetTaskTrayWindowRect() | |
180 | -// | |
181 | -BOOL bGetTaskTrayWindowRect(HWND hWnd, LPRECT lpRect) | |
182 | -{ | |
183 | - if (bTaskTray != FALSE) { | |
184 | - NOTIFYICONIDENTIFIER nii{}; | |
185 | - nii.cbSize = sizeof(NOTIFYICONIDENTIFIER); | |
186 | - nii.hWnd = hWnd; | |
187 | - nii.uID = NOTIFYICONDATA_ID; | |
188 | - nii.guidItem = GUID_NULL; | |
189 | - try { | |
190 | - throw Shell_NotifyIconGetRect(&nii, lpRect); | |
191 | - } | |
192 | - catch (HRESULT hResult) { | |
193 | - if (hResult != S_OK) { | |
194 | - return FALSE; | |
195 | - } | |
196 | - return TRUE; | |
197 | - } | |
198 | - catch (...) { | |
199 | - PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
200 | - return FALSE; | |
201 | - } | |
202 | - } | |
203 | - return FALSE; | |
204 | -} | |
205 | - | |
206 | -// | |
207 | -// WM_TASKTRAYEX | |
208 | -// Cls_OnTaskTrayEx() | |
209 | -// | |
210 | -void Cls_OnTaskTrayEx(HWND hWnd, UINT id, UINT uMsg) | |
211 | -{ | |
212 | - if (id != NOTIFYICONDATA_ID) { | |
213 | - return; | |
214 | - } | |
215 | - switch (uMsg) { | |
216 | - case WM_LBUTTONDOWN: | |
217 | - if (bOffChangedFocus) { | |
218 | - Cime->vIMEOpenCloseForced(hWnd, IMECLOSE); | |
219 | - } | |
220 | - [[fallthrough]]; // fallthrough is explicit | |
221 | - //break; | |
222 | - case WM_RBUTTONDOWN: | |
223 | - bDisplayIMEModeOnCursor = FALSE; | |
224 | - bDoModeDispByMouseBttnUp = FALSE; | |
225 | - bDrawNearCaret = FALSE; | |
226 | - | |
227 | - // Display menu when left & right button is clicked on task tray icon. | |
228 | - POINT pt{}; | |
229 | - GetCursorPos(&pt); | |
230 | - HMENU hMenu = LoadMenu(Resource->hLoad(), MAKEINTRESOURCE(IDR_TT_MENU)); | |
231 | - HMENU hSubMenu = GetSubMenu(hMenu, 0); | |
232 | - SetForegroundWindow(hWnd); | |
233 | - APPBARDATA stAppBarData{}; | |
234 | - stAppBarData.cbSize = sizeof(APPBARDATA); | |
235 | - stAppBarData.hWnd = hWnd; | |
236 | - SHAppBarMessage(ABM_GETTASKBARPOS, &stAppBarData); | |
237 | - UINT uFlags = 0; | |
238 | - switch (stAppBarData.uEdge) { | |
239 | - case ABE_TOP: | |
240 | - uFlags = TPM_RIGHTALIGN | TPM_TOPALIGN; | |
241 | - if (pt.y < stAppBarData.rc.bottom) pt.y = stAppBarData.rc.bottom; | |
242 | - break; | |
243 | - case ABE_BOTTOM: | |
244 | - uFlags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN; | |
245 | - if (pt.y > stAppBarData.rc.top) pt.y = stAppBarData.rc.top; | |
246 | - break; | |
247 | - case ABE_LEFT: | |
248 | - uFlags = TPM_LEFTALIGN | TPM_BOTTOMALIGN; | |
249 | - if (pt.x < stAppBarData.rc.right) pt.x = stAppBarData.rc.right; | |
250 | - break; | |
251 | - case ABE_RIGHT: | |
252 | - uFlags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN; | |
253 | - if (pt.x > stAppBarData.rc.left) pt.x = stAppBarData.rc.left; | |
254 | - break; | |
255 | - } | |
256 | - if (hAboutDlg != NULL) { | |
257 | - //EnableMenuItem(hSubMenu, IDR_TT_ABOUT, MF_BYCOMMAND | MF_DISABLED); | |
258 | - } | |
259 | - if (hSettingDlg != NULL) { | |
260 | - //EnableMenuItem(hSubMenu, IDR_TT_SETTING, MF_BYCOMMAND | MF_DISABLED); | |
261 | - } | |
262 | - TrackPopupMenu(hSubMenu, uFlags, pt.x, pt.y, 0, hWnd, NULL); | |
263 | - break; | |
264 | - } | |
265 | -} | |
266 | - | |
267 | -// | |
268 | -// vSettingDialog() | |
269 | -// | |
270 | -VOID vSettingDialog(HWND hWnd) | |
271 | -{ | |
272 | - if (hSettingDlg != NULL) { | |
273 | - SetForegroundWindow(hSettingDlg); | |
274 | - return; | |
275 | - } | |
276 | - DialogBox(Resource->hLoad(), MAKEINTRESOURCE(IDD_SETTING), hWnd, SettingDlg); | |
277 | -} | |
278 | - | |
279 | -// | |
280 | -// SettingDlg() | |
281 | -// | |
282 | -static INT_PTR CALLBACK SettingDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | |
283 | -{ | |
284 | - UNREFERENCED_PARAMETER(lParam); | |
285 | - switch (message) { | |
286 | - case WM_INITDIALOG: | |
287 | - hSettingDlg = hDlg; | |
288 | - { // Initialize | |
289 | - HICON hIcon = (HICON)LoadImage(Resource->hLoad(), MAKEINTRESOURCE(IDI_SMALL), IMAGE_ICON, 16, 16, 0); | |
290 | - bInitDlgCenter(hDlg, hIcon, (ICC_BAR_CLASSES | ICC_HOTKEY_CLASS)); | |
291 | - } | |
292 | - { // Combo Box | |
293 | - TCHAR lpText[MAX_LOADSTRING]; | |
294 | - if (LoadString(Resource->hLoad(), IDS_CMBX_LIST01, lpText, MAX_LOADSTRING) == 0) return (INT_PTR)FALSE; | |
295 | - SendDlgItemMessage(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)lpText); | |
296 | - if (LoadString(Resource->hLoad(), IDS_CMBX_LIST02, lpText, MAX_LOADSTRING) == 0) return (INT_PTR)FALSE; | |
297 | - SendDlgItemMessage(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)lpText); | |
298 | - } | |
299 | - { // Check Box | |
300 | - bSetCheckDlgButton(hDlg, IDC_CHECK1, Profile->lpstAppRegData->bDisplayIMEModeOnCursor); | |
301 | - bSetCheckDlgButton(hDlg, IDC_CHECK2, Profile->lpstAppRegData->bOffChangedFocus); | |
302 | - bSetCheckDlgButton(hDlg, IDC_CHECK3, Profile->lpstAppRegData->bForceHiragana); | |
303 | - bSetCheckDlgButton(hDlg, IDC_CHECK4, Profile->lpstAppRegData->bDoModeDispByIMEKeyDown); | |
304 | - bSetCheckDlgButton(hDlg, IDC_CHECK5, Profile->lpstAppRegData->bDoModeDispByMouseBttnUp); | |
305 | - bSetCheckDlgButton(hDlg, IDC_CHECK6, Profile->lpstAppRegData->bDoModeDispByCtrlUp); | |
306 | - bSetCheckDlgButton(hDlg, IDC_CHECK7, Profile->lpstAppRegData->bDrawNearCaret); | |
307 | - bSetCheckDlgButton(hDlg, IDC_CHECK8, Profile->lpstAppRegData->bEnableEPHelper); | |
308 | - } | |
309 | - { // Track Bar | |
310 | - vSetTrackbar(hDlg, IDC_SLIDER1, 16, 64, 8, Profile->lpstAppRegData->iCursorSize, 8); | |
311 | - vSetTrackbar(hDlg, IDC_SLIDER2, 8, 64, 8, Profile->lpstAppRegData->iModeSize, 8); | |
312 | - vSetTrackbar(hDlg, IDC_SLIDER3, 100, 800, 70, Profile->lpstAppRegData->dwDisplayModeTime, 70); | |
313 | - vSetTrackbar(hDlg, IDC_SLIDER4, 0, 1000, 100, Profile->lpstAppRegData->dwWaitWaveTime, 100); | |
314 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK3) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0) { | |
315 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
316 | - } | |
317 | - else { | |
318 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
319 | - } | |
320 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK4) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
321 | - else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
322 | - } | |
323 | - { // 既定の動作 | |
324 | - if (Profile->lpstAppRegData->bDisplayFocusWindowIME) { | |
325 | - SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, 0, 0); | |
326 | - //EnableWindow(GetDlgItem(hDlg, IDC_CHECK2), TRUE); | |
327 | - } | |
328 | - else { | |
329 | - SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, 1, 0); | |
330 | - //CheckDlgButton(hDlg, IDC_CHECK2, BST_UNCHECKED); | |
331 | - //EnableWindow(GetDlgItem(hDlg, IDC_CHECK2), FALSE); | |
332 | - } | |
333 | - } | |
334 | - SetFocus(GetDlgItem(hDlg, IDC_CHECK1)); | |
335 | - return (INT_PTR)TRUE; | |
336 | - case WM_HSCROLL: | |
337 | - { // Track Bar | |
338 | - if ((GetDlgItem(hDlg, IDC_SLIDER1) == (HWND)lParam) | |
339 | - || (GetDlgItem(hDlg, IDC_SLIDER2) == (HWND)lParam) | |
340 | - || (GetDlgItem(hDlg, IDC_SLIDER3) == (HWND)lParam) | |
341 | - || (GetDlgItem(hDlg, IDC_SLIDER4) == (HWND)lParam)) { | |
342 | - EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
343 | - } | |
344 | - } | |
345 | - break; | |
346 | - case WM_CTLCOLORDLG: | |
347 | - return (INT_PTR)GetStockObject(WHITE_BRUSH); // 背景の色 | |
348 | - case WM_CTLCOLORSTATIC: | |
349 | - case WM_CTLCOLOREDIT: | |
350 | - SetBkMode(((HDC)wParam), TRANSPARENT); | |
351 | - SetTextColor(((HDC)wParam), RGB(0, 0, 0)); // 文字の色 | |
352 | - return (INT_PTR)GetStockObject(WHITE_BRUSH); // 背景の色 | |
353 | - case WM_COMMAND: | |
354 | - switch (LOWORD(wParam)) { | |
355 | - case IDC_CHECK4: | |
356 | - case IDC_CHECK5: | |
357 | - case IDC_CHECK6: | |
358 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK5) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK6) == 0) { | |
359 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
360 | - } | |
361 | - else { | |
362 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
363 | - } | |
364 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK6) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
365 | - else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
366 | - [[fallthrough]]; // fallthrough is explicit | |
367 | - case IDC_CHECK1: | |
368 | - case IDC_CHECK2: | |
369 | - case IDC_CHECK3: | |
370 | - case IDC_CHECK7: | |
371 | - case IDC_CHECK8: | |
372 | - EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
373 | - break; | |
374 | - case IDC_COMBO1: | |
375 | - if (HIWORD(wParam) == CBN_SELCHANGE) { | |
376 | - switch (SendDlgItemMessage(hDlg, IDC_COMBO1, CB_GETCURSEL, 0, 0)) { | |
377 | - case 0: | |
378 | - //EnableWindow(GetDlgItem(hDlg, IDC_CHECK2), TRUE); | |
379 | - break; | |
380 | - case 1: | |
381 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK2) != 0) { | |
382 | - //CheckDlgButton(hDlg, IDC_CHECK2, BST_UNCHECKED); | |
383 | - } | |
384 | - //EnableWindow(GetDlgItem(hDlg, IDC_CHECK2), FALSE); | |
385 | - break; | |
386 | - default: | |
387 | - break; | |
388 | - } | |
389 | - EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
390 | - } | |
391 | - break; | |
392 | - case IDC_BUTTON1: | |
393 | - SetFocus(GetDlgItem(hDlg, IDC_CHECK1)); | |
394 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK5) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK6) == 0) { | |
395 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
396 | - } | |
397 | - else { | |
398 | - EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
399 | - } | |
400 | - if (IsDlgButtonChecked(hDlg, IDC_CHECK6) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
401 | - else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
402 | - [[fallthrough]]; // fallthrough is explicit | |
403 | - case IDOK: | |
404 | - Profile->lpstAppRegData->bDisplayIMEModeOnCursor = bGetDlgButtonChecked(hDlg, IDC_CHECK1); | |
405 | - Profile->lpstAppRegData->bOffChangedFocus = bGetDlgButtonChecked(hDlg, IDC_CHECK2); | |
406 | - Profile->lpstAppRegData->bForceHiragana = bGetDlgButtonChecked(hDlg, IDC_CHECK3); | |
407 | - Profile->lpstAppRegData->bDoModeDispByIMEKeyDown = bGetDlgButtonChecked(hDlg, IDC_CHECK4); | |
408 | - Profile->lpstAppRegData->bDoModeDispByMouseBttnUp = bGetDlgButtonChecked(hDlg, IDC_CHECK5); | |
409 | - Profile->lpstAppRegData->bDoModeDispByCtrlUp = bGetDlgButtonChecked(hDlg, IDC_CHECK6); | |
410 | - Profile->lpstAppRegData->bDrawNearCaret = bGetDlgButtonChecked(hDlg, IDC_CHECK7); | |
411 | - Profile->lpstAppRegData->bEnableEPHelper = bGetDlgButtonChecked(hDlg, IDC_CHECK8); | |
412 | - Profile->lpstAppRegData->iCursorSize = (int)dwGetTrackbarPos(hDlg, IDC_SLIDER1); | |
413 | - Profile->lpstAppRegData->iModeSize = (int)dwGetTrackbarPos(hDlg, IDC_SLIDER2); | |
414 | - Profile->lpstAppRegData->dwDisplayModeTime = dwGetTrackbarPos(hDlg, IDC_SLIDER3); | |
415 | - Profile->lpstAppRegData->dwWaitWaveTime = dwGetTrackbarPos(hDlg, IDC_SLIDER4); | |
416 | - switch (SendDlgItemMessage(hDlg, IDC_COMBO1, CB_GETCURSEL, 0, 0)) { | |
417 | - case 0: | |
418 | - Profile->lpstAppRegData->bDisplayFocusWindowIME = TRUE; | |
419 | - break; | |
420 | - case 1: | |
421 | - Profile->lpstAppRegData->bDisplayFocusWindowIME = FALSE; | |
422 | - break; | |
423 | - default: | |
424 | - break; | |
425 | - } | |
426 | - if (Profile != NULL) { | |
427 | - Profile->bSetProfileData(); // Set Registry data | |
428 | - } | |
429 | - vStopThreadHookTimer(hMainWnd); | |
430 | - if (!bStartThreadHookTimer(hMainWnd)) { | |
431 | - PostMessage(hMainWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
432 | - return (INT_PTR)FALSE; | |
433 | - } | |
434 | - if (LOWORD(wParam) == IDC_BUTTON1) { | |
435 | - EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), FALSE); | |
436 | - return (INT_PTR)FALSE; | |
437 | - } | |
438 | - [[fallthrough]]; // fallthrough is explicit | |
439 | - case IDCANCEL: | |
440 | - EndDialog(hDlg, LOWORD(wParam)); | |
441 | - if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) hSettingDlg = NULL; | |
442 | - return (INT_PTR)TRUE; | |
443 | - } | |
444 | - } | |
445 | - return (INT_PTR)FALSE; | |
446 | -} | |
447 | - | |
448 | -// | |
449 | -// bInitDlgCenter() | |
450 | -// | |
451 | -static BOOL bInitDlgCenter(HWND hDlg, HICON hIcon, DWORD dwICC) | |
452 | -{ | |
453 | - int cx = GetSystemMetrics(SM_CXSCREEN); | |
454 | - int cy = GetSystemMetrics(SM_CYSCREEN); | |
455 | - RECT rc{}; | |
456 | - GetWindowRect(hDlg, (LPRECT)&rc); | |
457 | - rc.right = rc.right - rc.left + 1; rc.bottom = rc.bottom - rc.top + 1; | |
458 | - rc.left = (cx - rc.right) / 2; rc.top = (cy - rc.bottom) / 2; | |
459 | - MoveWindow(hDlg, rc.left, rc.top, rc.right, rc.bottom, TRUE); | |
460 | - SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); | |
461 | - | |
462 | - // Initialize | |
463 | - INITCOMMONCONTROLSEX stICC{}; | |
464 | - stICC.dwSize = sizeof(INITCOMMONCONTROLSEX); | |
465 | - stICC.dwICC = dwICC; | |
466 | - return InitCommonControlsEx(&stICC); | |
467 | -} | |
468 | - | |
469 | -// | |
470 | -// bSetCheckDlgButton() | |
471 | -// | |
472 | -static BOOL bSetCheckDlgButton(HWND hDlg, int iIDButton, BOOL bCheck) | |
473 | -{ | |
474 | - UINT uCheck = 0; | |
475 | - if (bCheck) uCheck = BST_CHECKED; | |
476 | - else uCheck = BST_UNCHECKED; | |
477 | - if (!CheckDlgButton(hDlg, iIDButton, uCheck)) { | |
478 | - return FALSE; | |
479 | - } | |
480 | - return TRUE; | |
481 | -} | |
482 | - | |
483 | -// | |
484 | -// vSetTrackbar() | |
485 | -// | |
486 | -static VOID vSetTrackbar(HWND hDlg, int iIDTrackbar, int iRangeMin, int iRangeMax, int iTickFreq, int iPos, int iPageSize) | |
487 | -{ | |
488 | - SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETRANGE, TRUE, MAKELPARAM(iRangeMin, iRangeMax)); | |
489 | - SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETTICFREQ, iTickFreq, 0); | |
490 | - SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETPOS, TRUE, iPos); | |
491 | - SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETPAGESIZE, 0, iPageSize); | |
492 | -} | |
493 | - | |
494 | -// | |
495 | -// bGetDlgButtonChecked() | |
496 | -// | |
497 | -static BOOL bGetDlgButtonChecked(HWND hDlg, int iIDButton) | |
498 | -{ | |
499 | - if (IsDlgButtonChecked(hDlg, iIDButton) == 0) return FALSE; | |
500 | - else return TRUE; | |
501 | -} | |
502 | - | |
503 | -// | |
504 | -// dwGetTrackbarPos() | |
505 | -// | |
506 | -static DWORD dwGetTrackbarPos(HWND hDlg, int iIDTrackbar) | |
507 | -{ | |
508 | - return (DWORD)SendDlgItemMessage(hDlg, iIDTrackbar, TBM_GETPOS, NULL, NULL); | |
509 | -} | |
510 | - | |
511 | -// | |
512 | -// vGetSetProfileData() | |
513 | -// | |
514 | -VOID vGetSetProfileData() | |
515 | -{ | |
516 | - bDisplayIMEModeOnCursor = Profile->lpstAppRegData->bDisplayIMEModeOnCursor; | |
517 | - bOffChangedFocus = Profile->lpstAppRegData->bOffChangedFocus; | |
518 | - bDisplayFocusWindowIME = Profile->lpstAppRegData->bDisplayFocusWindowIME; | |
519 | - bDoModeDispByIMEKeyDown = Profile->lpstAppRegData->bDoModeDispByIMEKeyDown; | |
520 | - bDoModeDispByMouseBttnUp = Profile->lpstAppRegData->bDoModeDispByMouseBttnUp; | |
521 | - bDoModeDispByCtrlUp = Profile->lpstAppRegData->bDoModeDispByCtrlUp; | |
522 | - bDrawNearCaret = Profile->lpstAppRegData->bDrawNearCaret; | |
523 | - bEnableEPHelper = Profile->lpstAppRegData->bEnableEPHelper; | |
524 | - bMoveIMEToolbar = Profile->lpstAppRegData->bMoveIMEToolbar; | |
525 | - bIMEModeForced = Profile->lpstAppRegData->bIMEModeForced; | |
526 | -} | |
527 | 39 | |
528 | 40 | // |
529 | 41 | // class CPowerNotification |
@@ -583,11 +95,16 @@ BOOL CPowerNotification::PowerBroadcast(HWND hWnd, ULONG Type, POWERBROADCAST_S | ||
583 | 95 | case 0: |
584 | 96 | bReportEvent(MSG_PBT_APMPOWERSTATUSCHANGE_AC_OFF, POWERNOTIFICATION_CATEGORY); |
585 | 97 | Sleep(3000); |
586 | - bReportEvent(MSG_RESTART_EVENT, POWERNOTIFICATION_CATEGORY); | |
587 | - bDestroyTaskTrayWindow(hWnd); | |
98 | + vDestroyWindow(hWnd); | |
99 | + bCreateProcess(FLUSHMOUSE_EXE); | |
100 | + bReportEvent(MSG_RESTART_EVENT, POWERNOTIFICATION_CATEGORY); | |
588 | 101 | break; |
589 | 102 | case 1: |
590 | 103 | bReportEvent(MSG_PBT_APMPOWERSTATUSCHANGE_AC_ON, POWERNOTIFICATION_CATEGORY); |
104 | + Sleep(3000); | |
105 | + vDestroyWindow(hWnd); | |
106 | + bCreateProcess(FLUSHMOUSE_EXE); | |
107 | + bReportEvent(MSG_RESTART_EVENT, POWERNOTIFICATION_CATEGORY); | |
591 | 108 | break; |
592 | 109 | default: |
593 | 110 | break; |
@@ -637,19 +154,19 @@ BOOL CEventHook::bEventSet() | ||
637 | 154 | { |
638 | 155 | #define EVENT_FLAGS (WINEVENT_OUTOFCONTEXT) |
639 | 156 | hEventHook = SetWinEventHook( |
640 | - EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, // Range of events | |
641 | - NULL, // Handle to DLL. | |
642 | - &vHandleEvent, // The callback. | |
643 | - 0, 0, // Process and thread IDs of interest (0 = all) | |
644 | - EVENT_FLAGS); // Flags. | |
157 | + EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, | |
158 | + NULL, | |
159 | + &vHandleEvent, | |
160 | + 0, 0, | |
161 | + EVENT_FLAGS); | |
645 | 162 | if (hEventHook == NULL) return FALSE; |
646 | 163 | |
647 | 164 | hEventHookIME = SetWinEventHook( |
648 | - EVENT_OBJECT_TEXTSELECTIONCHANGED, EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED, // Range of events | |
649 | - NULL, // Handle to DLL. | |
650 | - &vHandleEventIME, // The callback. | |
651 | - 0, 0, // Process and thread IDs of interest (0 = all) | |
652 | - EVENT_FLAGS); // Flags. | |
165 | + EVENT_OBJECT_TEXTSELECTIONCHANGED, EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED, | |
166 | + NULL, | |
167 | + &vHandleEventIME, | |
168 | + 0, 0, | |
169 | + EVENT_FLAGS); | |
653 | 170 | if (hEventHookIME == NULL) return FALSE; |
654 | 171 | |
655 | 172 | return TRUE; |
@@ -741,8 +258,10 @@ CFlushMouseHook::CFlushMouseHook() | ||
741 | 258 | CFlushMouseHook::~CFlushMouseHook() |
742 | 259 | { |
743 | 260 | bHookUnset(); |
744 | - if (lpstProcessInfomation) delete[] lpstProcessInfomation; | |
745 | - lpstProcessInfomation = NULL; | |
261 | + if (lpstProcessInfomation) { | |
262 | + delete[] lpstProcessInfomation; | |
263 | + lpstProcessInfomation = NULL; | |
264 | + } | |
746 | 265 | } |
747 | 266 | // |
748 | 267 | // bHookSet() |
@@ -778,7 +297,7 @@ BOOL CFlushMouseHook::bHookUnset() | ||
778 | 297 | BOOL CFlushMouseHook::bHook32DllStart(HWND hWnd, LPCTSTR lpszExec32Name) |
779 | 298 | { |
780 | 299 | #define COMAMANDLINESIZE (sizeof(_T(" ")) * (sizeof(unsigned long long) + 1)) |
781 | - BOOL bRet = FALSE; | |
300 | + BOOL bRet = FALSE; | |
782 | 301 | DWORD dwSize = 0; |
783 | 302 | dwSize = ExpandEnvironmentStrings(lpszExec32Name, NULL, 0); |
784 | 303 | LPTSTR lpszBuffer = new TCHAR[dwSize]; |
@@ -813,7 +332,7 @@ BOOL CFlushMouseHook::bHook32DllStart(HWND hWnd, LPCTSTR lpszExec32Name) | ||
813 | 332 | BOOL CFlushMouseHook::bHook32DllStop() |
814 | 333 | { |
815 | 334 | #define TIMEOUT 1000 |
816 | - if (!bHook32Dll) return TRUE; | |
335 | + if (!bHook32Dll) return TRUE; | |
817 | 336 | BOOL bRet = FALSE; |
818 | 337 | if (lpstProcessInfomation != NULL) { |
819 | 338 | if (lpstProcessInfomation->hProcess != NULL) { |
@@ -1,9 +1,10 @@ | ||
1 | -// FlushMouseSub.h | |
1 | +// | |
2 | +// FlushMouseSub.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/03 JeffyTS New edit. | |
7 | +// #0000 2022/03/03 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -23,22 +24,10 @@ | ||
23 | 24 | // |
24 | 25 | // Global Data |
25 | 26 | // |
26 | -extern HWND hAboutDlg; | |
27 | -extern HWND hSettingDlg; | |
28 | -extern BOOL bIMEInConverting; | |
29 | 27 | |
30 | 28 | // |
31 | 29 | // Global Prototype Define |
32 | 30 | // |
33 | -extern BOOL bCreateTaskTrayWindow(HWND hWnd, HICON hIcon, LPCTSTR lpszTitile); | |
34 | -extern BOOL bReCreateTaskTrayWindow(HWND hWnd, UINT message); | |
35 | -extern BOOL bDestroyTaskTrayWindow(HWND hWnd); | |
36 | -extern BOOL bGetTaskTrayWindowRect(HWND hWnd, LPRECT lpRect); | |
37 | -extern void Cls_OnTaskTrayEx(HWND hWnd, UINT id, UINT uMsg); | |
38 | -extern void vMessageBox(HWND hWnd, UINT uID, UINT uType); | |
39 | -extern VOID vAboutDialog(HWND hWnd); | |
40 | -extern VOID vSettingDialog(HWND hWnd); | |
41 | -extern VOID vGetSetProfileData(); | |
42 | 31 | |
43 | 32 | // |
44 | 33 | // class CEventHook |
@@ -46,8 +35,9 @@ extern VOID vGetSetProfileData(); | ||
46 | 35 | class CEventHook |
47 | 36 | { |
48 | 37 | public: |
49 | - CEventHook(); | |
50 | - ~CEventHook(); | |
38 | + CEventHook(); | |
39 | + ~CEventHook(); | |
40 | + | |
51 | 41 | BOOL bEventSet(); |
52 | 42 | BOOL bEventUnset(); |
53 | 43 |
@@ -56,7 +46,7 @@ private: | ||
56 | 46 | static void CALLBACK vHandleEventIME(HWINEVENTHOOK hook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); |
57 | 47 | |
58 | 48 | public: |
59 | - HWND hFormerWnd; | |
49 | + HWND hFormerWnd; | |
60 | 50 | |
61 | 51 | private: |
62 | 52 | HWINEVENTHOOK hEventHook; |
@@ -71,12 +61,13 @@ class CPowerNotification | ||
71 | 61 | public: |
72 | 62 | CPowerNotification(HWND hWnd); |
73 | 63 | ~CPowerNotification(); |
64 | + | |
74 | 65 | BOOL PowerBroadcast(HWND hWnd, ULONG Type, POWERBROADCAST_SETTING* lpSetting); |
75 | 66 | |
76 | 67 | private: |
77 | - HPOWERNOTIFY hSuspendResumeNotification; | |
78 | - HPOWERNOTIFY hPowerSettingNotification; | |
79 | - GUID guidPowerSettingNotification; | |
68 | + HPOWERNOTIFY hSuspendResumeNotification; | |
69 | + HPOWERNOTIFY hPowerSettingNotification; | |
70 | + GUID guidPowerSettingNotification; | |
80 | 71 | }; |
81 | 72 | |
82 | 73 | // |
@@ -97,10 +88,10 @@ private: | ||
97 | 88 | |
98 | 89 | private: |
99 | 90 | HMODULE hHook64Dll; |
100 | - BOOL bGlobalHook64; | |
101 | - BOOL bKeyboardHookLL64; | |
102 | - BOOL bMouseHook64; | |
103 | - BOOL bHook32Dll; | |
91 | + BOOL bGlobalHook64; | |
92 | + BOOL bKeyboardHookLL64; | |
93 | + BOOL bMouseHook64; | |
94 | + BOOL bHook32Dll; | |
104 | 95 | |
105 | 96 | private: |
106 | 97 | LPPROCESS_INFORMATION lpstProcessInfomation; |
@@ -0,0 +1,327 @@ | ||
1 | +// | |
2 | +// Ime.cpp | |
3 | +// Copyright (C) 2022 JeffyTS | |
4 | +// | |
5 | +// No. Date Name Reason & Document | |
6 | +// -------+-----------+-----------+-------------------------------------------- - | |
7 | +// #0000 2022/03/03 JeffyTS New edit. | |
8 | +// #0001 2023/06/30 JeffyTS Divided from cursor.cpp | |
9 | +// | |
10 | + | |
11 | +// Include | |
12 | +// | |
13 | +#pragma once | |
14 | +#include "pch.h" | |
15 | +#include "Ime.h" | |
16 | +#include "CommonDef.h" | |
17 | +#include "..\MiscLIB\CRegistry.h" | |
18 | + | |
19 | +// | |
20 | +// Library | |
21 | +// | |
22 | + | |
23 | +// | |
24 | +// Define | |
25 | +// | |
26 | + | |
27 | +// | |
28 | +// Struct Define | |
29 | +// | |
30 | + | |
31 | +// | |
32 | +// Class Define | |
33 | + | |
34 | +// | |
35 | +// Local Data | |
36 | +// | |
37 | + | |
38 | +// | |
39 | +// Class CIME | |
40 | +// | |
41 | +CIME::CIME() | |
42 | +{ | |
43 | + lpstVirtualDesktop = new VIRTUALDESKTOP[sizeof(VIRTUALDESKTOP)]; | |
44 | + if (lpstVirtualDesktop != NULL) { | |
45 | + ZeroMemory(lpstVirtualDesktop, sizeof(VIRTUALDESKTOP)); | |
46 | + bGetVirtualDesktopSize(); | |
47 | + } | |
48 | +} | |
49 | +CIME::~CIME() | |
50 | +{ | |
51 | + if (lpstVirtualDesktop != NULL) delete[] lpstVirtualDesktop; | |
52 | + lpstVirtualDesktop = NULL; | |
53 | +} | |
54 | + | |
55 | +// | |
56 | +// bIsIMEOpen() | |
57 | +// | |
58 | +BOOL CIME::bIsIMEOpen(HWND hWndObserved) | |
59 | +{ | |
60 | + HWND hIMWnd = NULL; | |
61 | + if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
62 | + if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETOPENSTATUS, (LPARAM)NULL) != 0) { | |
63 | + return TRUE; | |
64 | + } | |
65 | + } | |
66 | + return FALSE; | |
67 | +} | |
68 | + | |
69 | +// | |
70 | +// vIMEOpenCloseForced() | |
71 | +// | |
72 | +VOID CIME::vIMEOpenCloseForced(HWND hWndObserved, DWORD dwIMEOpenClose) | |
73 | +{ | |
74 | + if (hWndObserved == NULL) return; | |
75 | + LPARAM lParam = (LPARAM)dwIMEOpenClose; | |
76 | + EnumChildWindows(hWndObserved, &bEnumChildProcIMEOpenClose, lParam); | |
77 | + return; | |
78 | +} | |
79 | + | |
80 | +// | |
81 | +// vIMEConvertModeChangeForced() | |
82 | +// | |
83 | +VOID CIME::vIMEConvertModeChangeForced(HWND hWndObserved, DWORD dwConvertMode) | |
84 | +{ | |
85 | + if (hWndObserved == NULL) return; | |
86 | + LPARAM lParam = (LPARAM)dwConvertMode; | |
87 | + EnumChildWindows(hWndObserved, &bEnumChildProcIMEConvertMode, lParam); | |
88 | + return; | |
89 | +} | |
90 | + | |
91 | +// | |
92 | +// bEnumChildProcIMEConvertMode() | |
93 | +// | |
94 | +BOOL CALLBACK CIME::bEnumChildProcIMEConvertMode(HWND hWndObserved, LPARAM lParam) | |
95 | +{ | |
96 | + if (hWndObserved == NULL) return FALSE; | |
97 | + HWND hIMWnd = NULL; | |
98 | + if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
99 | + if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETOPENSTATUS, (LPARAM)TRUE) == 0) { | |
100 | + if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETCONVERSIONMODE, (LPARAM)lParam) == 0) { | |
101 | + } | |
102 | + } | |
103 | + } | |
104 | + return TRUE; | |
105 | +} | |
106 | + | |
107 | +// | |
108 | +// bEnumChildProcIMEOpenClose() | |
109 | +// | |
110 | +BOOL CALLBACK CIME::bEnumChildProcIMEOpenClose(HWND hWndObserved, LPARAM lParam) | |
111 | +{ | |
112 | + if (hWndObserved == NULL) return FALSE; | |
113 | + HWND hIMWnd = NULL; | |
114 | + if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
115 | + if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_SETOPENSTATUS, lParam) == 0) { | |
116 | + } | |
117 | + } | |
118 | + return TRUE; | |
119 | +} | |
120 | + | |
121 | +// | |
122 | +// dwIMEMode() | |
123 | +// | |
124 | +DWORD CIME::dwIMEMode(HWND hWndObserved, BOOL bForceHiragana) | |
125 | +{ | |
126 | + if (hWndObserved != NULL) { | |
127 | + HWND hIMWnd = NULL; | |
128 | + HKL hkl = NULL; | |
129 | + DWORD dwInputLocale = 0; | |
130 | + DWORD dwConvertMode = 0; | |
131 | + if ((hIMWnd = ImmGetDefaultIMEWnd(hWndObserved)) != NULL) { | |
132 | + if (SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETOPENSTATUS, NULL) != 0) { | |
133 | + if ((dwConvertMode = (DWORD)SendMessage(hIMWnd, WM_IME_CONTROL, (WPARAM)IMC_GETCONVERSIONMODE, NULL)) != 0) { | |
134 | + switch (dwConvertMode) { | |
135 | + case IME_CMODE_NATIVE: | |
136 | + dwConvertMode = IMEOFF; | |
137 | + break; | |
138 | + case ZENHIRA_IMEON: | |
139 | + case (ZENHIRA_IMEON ^ IME_CMODE_ROMAN): | |
140 | + dwConvertMode = ZENHIRA_IMEON; | |
141 | + break; | |
142 | + case HANEISU_IMEON: | |
143 | + case (HANEISU_IMEON ^ IME_CMODE_ROMAN): | |
144 | + dwConvertMode = HANEISU_IMEON; | |
145 | + break; | |
146 | + case HANKANA_IMEON: | |
147 | + case (HANKANA_IMEON ^ IME_CMODE_ROMAN): | |
148 | + dwConvertMode = HANKANA_IMEON; | |
149 | + break; | |
150 | + case ZENEISU_IMEON: | |
151 | + case (ZENEISU_IMEON ^ IME_CMODE_ROMAN): | |
152 | + dwConvertMode = ZENEISU_IMEON; | |
153 | + break; | |
154 | + case ZENKANA_IMEON: | |
155 | + case (ZENKANA_IMEON ^ IME_CMODE_ROMAN): | |
156 | + dwConvertMode = ZENKANA_IMEON; | |
157 | + break; | |
158 | + default: | |
159 | + dwConvertMode = IMEOFF; | |
160 | + } | |
161 | + if ((bForceHiragana != FALSE) && (dwConvertMode != ZENHIRA_IMEON)) { | |
162 | + vIMEConvertModeChangeForced(hWndObserved, ZENHIRA_IMEON); | |
163 | + dwConvertMode = ZENHIRA_IMEON; | |
164 | + } | |
165 | + if ((hkl = hklGetInputLocale(hWndObserved)) != (HKL)0) { | |
166 | + if ((dwInputLocale = dwGetInputLocale()) != 0) { | |
167 | + if ((hkl = (HKL)(((UINT64)hkl & KB_MASK) | (dwInputLocale & LANG_MASK))) != JP_IME) { | |
168 | + dwConvertMode = IMEOFF; | |
169 | + } | |
170 | + } | |
171 | + } | |
172 | + return dwConvertMode; | |
173 | + } | |
174 | + } | |
175 | + } | |
176 | + } | |
177 | + return IMEOFF; | |
178 | +} | |
179 | + | |
180 | +// | |
181 | +// vActivateIME() | |
182 | +// | |
183 | +VOID CIME::vActivateIME(HWND hWndObserved) | |
184 | +{ | |
185 | + EnumChildWindows(hWndObserved, &bEnumChildProcActivateIME, NULL); | |
186 | +} | |
187 | + | |
188 | +// | |
189 | +// bEnumChildProcActivateIME() | |
190 | +// | |
191 | +BOOL CALLBACK CIME::bEnumChildProcActivateIME(HWND hWnd, LPARAM lParam) | |
192 | +{ | |
193 | + UNREFERENCED_PARAMETER(lParam); | |
194 | + | |
195 | + HWND hIMWnd = ImmGetDefaultIMEWnd(hWnd); | |
196 | + if (hIMWnd != NULL) { | |
197 | + SendMessage(hIMWnd, WM_ACTIVATE, (WPARAM)WA_ACTIVE, (LPARAM)NULL); | |
198 | + LPTSTR lpszBuffer = new TCHAR[_MAX_PATH]; | |
199 | + if (lpszBuffer) { | |
200 | + ZeroMemory(lpszBuffer, (sizeof(TCHAR) * _MAX_PATH)); | |
201 | + if (GetClassName(hIMWnd, lpszBuffer, _MAX_PATH) != 0) { | |
202 | + HWND hIMEWnd = FindWindow(lpszBuffer, NULL); | |
203 | + if (hIMEWnd != NULL) { | |
204 | + SendMessage(hIMEWnd, WM_ACTIVATE, (WPARAM)WA_ACTIVE, (LPARAM)NULL); | |
205 | + delete[] lpszBuffer; | |
206 | + return TRUE; | |
207 | + } | |
208 | + } | |
209 | + delete[] lpszBuffer; | |
210 | + } | |
211 | + } | |
212 | + return TRUE; | |
213 | +} | |
214 | + | |
215 | + | |
216 | +// | |
217 | +// bGetVirtualDesktopSize() | |
218 | +// | |
219 | +BOOL CIME::bGetVirtualDesktopSize() | |
220 | +{ | |
221 | + BOOL bRet = FALSE; | |
222 | + if (lpstVirtualDesktop != NULL) { | |
223 | + ZeroMemory(lpstVirtualDesktop, sizeof(VIRTUALDESKTOP)); | |
224 | + if (EnumDisplayMonitors(NULL, NULL, (MONITORENUMPROC)&bGetVirtualDesktopSizeEnumProc, (LPARAM)lpstVirtualDesktop) != 0) { | |
225 | + bRet = TRUE; | |
226 | + } | |
227 | + else { | |
228 | + _Post_equals_last_error_ DWORD err = GetLastError(); | |
229 | + if ((err == ERROR_INVALID_PARAMETER) || (err == ERROR_SUCCESS)) { | |
230 | + bRet = TRUE; | |
231 | + } | |
232 | + else if (err == ERROR_ACCESS_DENIED) { | |
233 | + // error but be able to On Sleep | |
234 | + bRet = TRUE; | |
235 | + } | |
236 | + } | |
237 | + } | |
238 | + return bRet; | |
239 | +} | |
240 | + | |
241 | +// | |
242 | +// bGetVirtualDesktopSizeEnumProc() | |
243 | +// | |
244 | +BOOL CIME::bGetVirtualDesktopSizeEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam) | |
245 | +{ | |
246 | + UNREFERENCED_PARAMETER(hDC); | |
247 | + UNREFERENCED_PARAMETER(lprcClip); | |
248 | + LPVIRTUALDESKTOP lpstVirtualDesktop = (LPVIRTUALDESKTOP)lParam; | |
249 | + //CIME* This = reinterpret_cast<CIME*>(lParam); | |
250 | + MONITORINFO stMonInfo{}; stMonInfo.cbSize = sizeof(MONITORINFO); | |
251 | + if (GetMonitorInfo(hMonitor, &stMonInfo) != 0) { | |
252 | + if (stMonInfo.rcMonitor.left <= lpstVirtualDesktop->rcMonitorSize.left) lpstVirtualDesktop->rcMonitorSize.left = stMonInfo.rcMonitor.left; | |
253 | + if (stMonInfo.rcMonitor.right >= lpstVirtualDesktop->rcMonitorSize.right) lpstVirtualDesktop->rcMonitorSize.right = stMonInfo.rcMonitor.right; | |
254 | + if (stMonInfo.rcMonitor.top <= lpstVirtualDesktop->rcMonitorSize.top) lpstVirtualDesktop->rcMonitorSize.top = stMonInfo.rcMonitor.top; | |
255 | + if (stMonInfo.rcMonitor.bottom >= lpstVirtualDesktop->rcMonitorSize.bottom) lpstVirtualDesktop->rcMonitorSize.bottom = stMonInfo.rcMonitor.bottom; | |
256 | + ++lpstVirtualDesktop->iNumOfMonitors; | |
257 | + return TRUE; | |
258 | + } | |
259 | + return FALSE; | |
260 | +} | |
261 | + | |
262 | +// | |
263 | +// bIsNewIME() | |
264 | +// | |
265 | +// | |
266 | +BOOL CIME::bIsNewIME() | |
267 | +{ | |
268 | +#define SUBKEY _T("Software\\Microsoft\\input\\tsf\\tsf3override\\{03b5835f-f03c-411b-9ce2-aa23e1171e36}") | |
269 | +#define VALUE _T("NoTsf3Override2") | |
270 | + CRegistry* CReg = new CRegistry; | |
271 | + if (CReg) { | |
272 | + DWORD dwCTF = 0; | |
273 | + if (!CReg->bReadSystemRegValueDWORD(HKEY_CURRENT_USER, SUBKEY, VALUE, &dwCTF)) { | |
274 | + dwCTF = 0; | |
275 | + } | |
276 | + delete CReg; | |
277 | + if (dwCTF != 0) return FALSE; | |
278 | + else return TRUE; | |
279 | + } | |
280 | + return FALSE; | |
281 | +#undef SUBKEY | |
282 | +#undef VALUE | |
283 | +} | |
284 | + | |
285 | +// | |
286 | +// dGetInputLocale() | |
287 | +// | |
288 | +DWORD CIME::dwGetInputLocale() | |
289 | +{ | |
290 | +#define SUBKEY _T("SOFTWARE\\Microsoft\\Input\\Locales") | |
291 | +#define VALUE _T("InputLocale") | |
292 | + DWORD dwInputLocale = 0; | |
293 | + CRegistry* CReg = new CRegistry; | |
294 | + if (CReg) { | |
295 | + if (!CReg->bReadSystemRegValueDWORD(HKEY_LOCAL_MACHINE, SUBKEY, VALUE, &dwInputLocale)) { | |
296 | + } | |
297 | + delete CReg; | |
298 | + } | |
299 | + return (dwInputLocale & 0x0000ffff); | |
300 | +#undef SUBKEY | |
301 | +#undef VALUE | |
302 | +} | |
303 | + | |
304 | +// | |
305 | +// hklGetInputLocale() | |
306 | +// | |
307 | +HKL CIME::hklGetInputLocale(HWND hWndObserved) | |
308 | +{ | |
309 | + | |
310 | + DWORD dwProcessID = 0; | |
311 | + DWORD dwThreadID = 0; | |
312 | + HKL hkl = NULL; | |
313 | + DWORD dwInputLocale = 0; | |
314 | + if ((dwThreadID = GetWindowThreadProcessId(hWndObserved, &dwProcessID)) != 0) { | |
315 | + if ((hkl = GetKeyboardLayout(dwThreadID)) != NULL) { | |
316 | + int iKeyboardType = GetKeyboardType(1); | |
317 | + if ((iKeyboardType != 2) || (hkl != JP_IME)) hkl = US_ENG; | |
318 | + hkl = (HKL)(((UINT64)hkl & KB_MASK) | (dwInputLocale & LANG_MASK)); | |
319 | + return hkl; | |
320 | + } | |
321 | + } | |
322 | + return (HKL)0; | |
323 | +#undef SUBKEY | |
324 | +#undef VALUE | |
325 | +} | |
326 | + | |
327 | +/* = EOF = */ | |
\ No newline at end of file |
@@ -0,0 +1,72 @@ | ||
1 | +// Ime.h | |
2 | +// Copyright (C) 2022 JeffyTS | |
3 | +// | |
4 | +// No. Date Name Reason & Document | |
5 | +// -------+-----------+-----------+-------------------------------------------- - | |
6 | +// #0000 2022/03/12 JeffyTS New edit. | |
7 | +// #0001 2023/06/30 JeffyTS Divided from cursor.h | |
8 | + | |
9 | +// | |
10 | +// Include | |
11 | +// | |
12 | +#pragma once | |
13 | +#include "pch.h" | |
14 | + | |
15 | +// | |
16 | +// Define | |
17 | +// | |
18 | +#define IMEMODECHAR 3 | |
19 | + | |
20 | +// IME mode | |
21 | +#define IMECLOSE 0x0000 | |
22 | +#define IMEOPEN 0x0001 | |
23 | +#define IMEOFF (IME_CMODE_ALPHANUMERIC) // 0x00 : A 英数(直接入力) | |
24 | +#define HANEISU_IMEON (IME_CMODE_ROMAN | IME_CMODE_ALPHANUMERIC) // 0x10 :_A 半角英数 0001 0000 | |
25 | +#define HANKANA_IMEON (IME_CMODE_ROMAN | IME_CMODE_KATAKANA | IME_CMODE_NATIVE) // 0x13 :_カ 半角カナ 0001 0011 | |
26 | +#define ZENEISU_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE) // 0x18 :A 全角英数 0001 1000 | |
27 | +#define ZENHIRA_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_NATIVE) // 0x19 :あ 全角ひら 0001 1001(漢字変換モード) | |
28 | +#define ZENKANA_IMEON (IME_CMODE_ROMAN | IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA | IME_CMODE_NATIVE) // 0x1B :カ 全角カナ 0001 1011 | |
29 | +#define IMEHIDE (0x88) // 0x88 :■ Hide 1001 1000 | |
30 | + | |
31 | +// | |
32 | +// Struct Define | |
33 | +// | |
34 | +typedef struct tagVirtualDesktop | |
35 | +{ | |
36 | + RECT rcMonitorSize; | |
37 | + int iNumOfMonitors; | |
38 | +} VIRTUALDESKTOP, * PVIRTUALDESKTOP, * LPVIRTUALDESKTOP; | |
39 | + | |
40 | +// | |
41 | +// Class CIME | |
42 | +// | |
43 | +class CIME | |
44 | +{ | |
45 | +public: | |
46 | + CIME(); | |
47 | + ~CIME(); | |
48 | + | |
49 | +public: | |
50 | + BOOL bIsIMEOpen(HWND hWndObserved); | |
51 | + VOID vIMEOpenCloseForced(HWND hWndObserved, DWORD dwIMEOpenClose); | |
52 | + VOID vIMEConvertModeChangeForced(HWND hWndObserved, DWORD dwConvertMode); | |
53 | + DWORD dwIMEMode(HWND hWndObserved, BOOL bForceHiragana); | |
54 | + VOID vActivateIME(HWND hWndObserved); | |
55 | + BOOL bGetVirtualDesktopSize(); | |
56 | + BOOL bIsNewIME(); | |
57 | + DWORD dwGetInputLocale(); | |
58 | + HKL hklGetInputLocale(HWND hWndObserved); | |
59 | + | |
60 | +private: | |
61 | + static BOOL bGetVirtualDesktopSizeEnumProc(HMONITOR hMonitor, HDC hDC, LPCRECT lprcClip, LPARAM lParam); | |
62 | + | |
63 | + static BOOL CALLBACK bEnumChildProcIMEOpenClose(HWND hWnd, LPARAM lParam); | |
64 | + static BOOL CALLBACK bEnumChildProcIMEConvertMode(HWND hWnd, LPARAM lParam); | |
65 | + static BOOL CALLBACK bEnumChildProcActivateIME(HWND hWnd, LPARAM lParam); | |
66 | + | |
67 | +private: | |
68 | + LPVIRTUALDESKTOP lpstVirtualDesktop; | |
69 | +}; | |
70 | + | |
71 | + | |
72 | +/* = EOF = */ | |
\ No newline at end of file |
@@ -1,9 +1,10 @@ | ||
1 | -// Profile.cpp | |
1 | +// | |
2 | +// Profile.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/23 JeffyTS New edit. | |
7 | +// #0000 2022/03/23 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -1,9 +1,10 @@ | ||
1 | -// Profile.h | |
1 | +// | |
2 | +// Profile.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/23 JeffyTS New edit. | |
7 | +// #0000 2022/03/23 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -0,0 +1,527 @@ | ||
1 | +// | |
2 | +// TaskTray.cpp | |
3 | +// Copyright (C) 2022 JeffyTS | |
4 | +// | |
5 | +// No. Date Name Reason & Document | |
6 | +// -------+-----------+-----------+-------------------------------------------- - | |
7 | +// #0000 2022/03/03 JeffyTS New edit. | |
8 | +// #0001 2023/06/30 JeffyTS Divided from FlushMouseSub.cpp | |
9 | +// | |
10 | + | |
11 | +// Include | |
12 | +// | |
13 | +#pragma once | |
14 | +#include "pch.h" | |
15 | +#include "TaskTray.h" | |
16 | +#include "CommonDef.h" | |
17 | +#include "Resource.h" | |
18 | +#include "FlushMouseLIB.h" | |
19 | +#include "..\FlushMouseDLL\EventlogDll.h" | |
20 | + | |
21 | +// | |
22 | +// Library | |
23 | +// | |
24 | + | |
25 | +// | |
26 | +// Define | |
27 | +// | |
28 | + | |
29 | +// | |
30 | +// Struct Define | |
31 | +// | |
32 | + | |
33 | +// | |
34 | +// Global Data | |
35 | +// | |
36 | +HWND hAboutDlg = NULL; | |
37 | +HWND hSettingDlg = NULL; | |
38 | +BOOL bIMEInConverting = FALSE; | |
39 | + | |
40 | +// | |
41 | +// Local Data | |
42 | +// | |
43 | +static BOOL bTaskTray = FALSE; | |
44 | +static UINT uTaskbarCreatedMessage = 0; | |
45 | + | |
46 | +// | |
47 | +// Local Prototype Define | |
48 | +// | |
49 | +static INT_PTR CALLBACK SettingDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); | |
50 | +static BOOL bInitDlgCenter(HWND hDlg, HICON hIcon, DWORD dwICC); | |
51 | +static BOOL bSetCheckDlgButton(HWND hDlg, int iIDButton, BOOL bCheck); | |
52 | +static VOID vSetTrackbar(HWND hDlg, int iIDTrackbar, int iRangeMin, int iRangeMax, int iTickFreq, int iPos, int iPageSize); | |
53 | +static BOOL bGetDlgButtonChecked(HWND hDlg, int iIDButton); | |
54 | +static DWORD dwGetTrackbarPos(HWND hDlg, int iIDTrackbar); | |
55 | + | |
56 | +// | |
57 | +// bCreateTaskTrayWindow() | |
58 | +// | |
59 | +BOOL bCreateTaskTrayWindow(HWND hWnd, HICON hIcon, LPCTSTR lpszTitle) | |
60 | +{ | |
61 | + NOTIFYICONDATA nIco{}; | |
62 | + nIco.cbSize = sizeof(NOTIFYICONDATA); | |
63 | + nIco.hWnd = hWnd; | |
64 | + nIco.uID = NOTIFYICONDATA_ID; | |
65 | + nIco.guidItem = GUID_NULL; | |
66 | + nIco.uFlags = NIF_INFO | NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
67 | + nIco.uCallbackMessage = WM_TASKTRAYEX; | |
68 | + nIco.dwState = NIS_HIDDEN | NIS_SHAREDICON; | |
69 | + nIco.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON | NIIF_NOSOUND; | |
70 | + nIco.uVersion = NOTIFYICON_VERSION_4; | |
71 | + nIco.hIcon = hIcon; | |
72 | + if ((nIco.hIcon = LoadIcon(Resource->hLoad(), MAKEINTRESOURCE(IDI_FLUSHMOUSE))) == NULL) { | |
73 | + return FALSE; | |
74 | + } | |
75 | + _tcsncpy_s(nIco.szTip, ARRAYSIZE(nIco.szTip), lpszTitle, _TRUNCATE); | |
76 | + try { | |
77 | + throw Shell_NotifyIcon(NIM_ADD, &nIco); | |
78 | + } | |
79 | + catch (BOOL bRet) { | |
80 | + if (!bRet) { | |
81 | + _Post_equals_last_error_ DWORD err = GetLastError(); | |
82 | + if (err == ERROR_TIMEOUT) { | |
83 | + Sleep(1000); | |
84 | + try { | |
85 | + throw Shell_NotifyIcon(NIM_ADD, &nIco); | |
86 | + } | |
87 | + catch (BOOL bRet) { | |
88 | + if (!bRet) { | |
89 | + return FALSE; | |
90 | + } | |
91 | + } | |
92 | + catch (...) { | |
93 | + return FALSE; | |
94 | + } | |
95 | + } | |
96 | + else { | |
97 | + return FALSE; | |
98 | + } | |
99 | + } | |
100 | + } | |
101 | + catch (...) { | |
102 | + return FALSE; | |
103 | + } | |
104 | + | |
105 | + if ((uTaskbarCreatedMessage = RegisterWindowMessage(_T("TaskbarCreated"))) == 0) { | |
106 | + bDestroyTaskTrayWindow(hWnd); | |
107 | + return FALSE; | |
108 | + } | |
109 | + bTaskTray = TRUE; | |
110 | + return TRUE; | |
111 | +} | |
112 | + | |
113 | + | |
114 | +// | |
115 | +// bReCreateTaskTrayWindow() | |
116 | +// | |
117 | +BOOL bReCreateTaskTrayWindow(HWND hWnd, UINT message) | |
118 | +{ | |
119 | + if (message == uTaskbarCreatedMessage) { | |
120 | + if (bDestroyTaskTrayWindow(hWnd)) { | |
121 | + bTaskTray = FALSE; | |
122 | + } | |
123 | + HICON hIcon = NULL; | |
124 | + if ((hIcon = LoadIcon(Resource->hLoad(), MAKEINTRESOURCE(IDI_FLUSHMOUSE))) != NULL) { | |
125 | + if (bCreateTaskTrayWindow(hWnd, hIcon, szTitle)) { | |
126 | + bTaskTray = TRUE; | |
127 | + vStopThreadHookTimer(hWnd); | |
128 | + if (!bStartThreadHookTimer(hWnd)) { | |
129 | + bReportEvent(MSG_THREAD_HOOK_TIMER_RESTART_FAILED, APPLICATION_CATEGORY); | |
130 | + PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
131 | + } | |
132 | + bReportEvent(MSG_THREAD_HOOK_TIMER_RESTARTED, APPLICATION_CATEGORY); | |
133 | + return TRUE; | |
134 | + } | |
135 | + else { | |
136 | + if (bDestroyTaskTrayWindow(hWnd)) { | |
137 | + bTaskTray = FALSE; | |
138 | + } | |
139 | + bReportEvent(MSG_TASKTRAY_REGISTER_FAILD, APPLICATION_CATEGORY); | |
140 | + bReportEvent(MSG_RESTART_EVENT, APPLICATION_CATEGORY); | |
141 | + return TRUE; | |
142 | + } | |
143 | + } | |
144 | + else { | |
145 | + return FALSE; | |
146 | + } | |
147 | + } | |
148 | + return TRUE; | |
149 | +} | |
150 | + | |
151 | +// | |
152 | +// bDestroyTaskTrayWindow() | |
153 | +// | |
154 | +BOOL bDestroyTaskTrayWindow(HWND hWnd) | |
155 | +{ | |
156 | + if (bTaskTray != FALSE) { | |
157 | + NOTIFYICONDATA nIco{}; | |
158 | + nIco.cbSize = sizeof(NOTIFYICONDATA); | |
159 | + nIco.hWnd = hWnd; | |
160 | + nIco.uID = NOTIFYICONDATA_ID; | |
161 | + nIco.guidItem = GUID_NULL; | |
162 | + nIco.uFlags = 0; | |
163 | + try { | |
164 | + throw Shell_NotifyIcon(NIM_DELETE, &nIco); | |
165 | + } | |
166 | + catch (BOOL bRet) { | |
167 | + if (bRet) { | |
168 | + bTaskTray = FALSE; | |
169 | + return TRUE; | |
170 | + } | |
171 | + else { | |
172 | + return FALSE; | |
173 | + } | |
174 | + } | |
175 | + catch (...) { | |
176 | + return FALSE; | |
177 | + } | |
178 | + } | |
179 | + return TRUE; | |
180 | +} | |
181 | + | |
182 | +// | |
183 | +// bGetTaskTrayWindowRect() | |
184 | +// | |
185 | +BOOL bGetTaskTrayWindowRect(HWND hWnd, LPRECT lpRect) | |
186 | +{ | |
187 | + if (bTaskTray != FALSE) { | |
188 | + NOTIFYICONIDENTIFIER nii{}; | |
189 | + nii.cbSize = sizeof(NOTIFYICONIDENTIFIER); | |
190 | + nii.hWnd = hWnd; | |
191 | + nii.uID = NOTIFYICONDATA_ID; | |
192 | + nii.guidItem = GUID_NULL; | |
193 | +#ifdef _DEBUG | |
194 | + HRESULT hResult = E_FAIL; | |
195 | + if ((hResult = Shell_NotifyIconGetRect(&nii, lpRect)) != S_OK) { | |
196 | + return FALSE; | |
197 | + } | |
198 | + return TRUE; | |
199 | + } | |
200 | +#else | |
201 | + try { | |
202 | + throw Shell_NotifyIconGetRect(&nii, lpRect); | |
203 | + } | |
204 | + catch (HRESULT hResult) { | |
205 | + if (hResult != S_OK) { | |
206 | + return FALSE; | |
207 | + } | |
208 | + return TRUE; | |
209 | + } | |
210 | + catch (...) { | |
211 | + PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
212 | + return FALSE; | |
213 | + } | |
214 | + } | |
215 | +#endif // _DEBUG | |
216 | + return FALSE; | |
217 | +} | |
218 | + | |
219 | +// | |
220 | +// WM_TASKTRAYEX | |
221 | +// Cls_OnTaskTrayEx() | |
222 | +// | |
223 | +void Cls_OnTaskTrayEx(HWND hWnd, UINT id, UINT uMsg) | |
224 | +{ | |
225 | + if (id != NOTIFYICONDATA_ID) { | |
226 | + return; | |
227 | + } | |
228 | + switch (uMsg) { | |
229 | + case WM_LBUTTONDOWN: | |
230 | + if (bOffChangedFocus) { | |
231 | + Cime->vIMEOpenCloseForced(hWnd, IMECLOSE); | |
232 | + } | |
233 | + [[fallthrough]]; | |
234 | + //break; | |
235 | + case WM_RBUTTONDOWN: | |
236 | + bDisplayIMEModeOnCursor = FALSE; | |
237 | + bDoModeDispByMouseBttnUp = FALSE; | |
238 | + bDrawNearCaret = FALSE; | |
239 | + | |
240 | + POINT pt{}; | |
241 | + GetCursorPos(&pt); | |
242 | + HMENU hMenu = LoadMenu(Resource->hLoad(), MAKEINTRESOURCE(IDR_TT_MENU)); | |
243 | + HMENU hSubMenu = GetSubMenu(hMenu, 0); | |
244 | + SetForegroundWindow(hWnd); | |
245 | + APPBARDATA stAppBarData{}; | |
246 | + stAppBarData.cbSize = sizeof(APPBARDATA); | |
247 | + stAppBarData.hWnd = hWnd; | |
248 | + SHAppBarMessage(ABM_GETTASKBARPOS, &stAppBarData); | |
249 | + UINT uFlags = 0; | |
250 | + switch (stAppBarData.uEdge) { | |
251 | + case ABE_TOP: | |
252 | + uFlags = TPM_RIGHTALIGN | TPM_TOPALIGN; | |
253 | + if (pt.y < stAppBarData.rc.bottom) pt.y = stAppBarData.rc.bottom; | |
254 | + break; | |
255 | + case ABE_BOTTOM: | |
256 | + uFlags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN; | |
257 | + if (pt.y > stAppBarData.rc.top) pt.y = stAppBarData.rc.top; | |
258 | + break; | |
259 | + case ABE_LEFT: | |
260 | + uFlags = TPM_LEFTALIGN | TPM_BOTTOMALIGN; | |
261 | + if (pt.x < stAppBarData.rc.right) pt.x = stAppBarData.rc.right; | |
262 | + break; | |
263 | + case ABE_RIGHT: | |
264 | + uFlags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN; | |
265 | + if (pt.x > stAppBarData.rc.left) pt.x = stAppBarData.rc.left; | |
266 | + break; | |
267 | + } | |
268 | + TrackPopupMenu(hSubMenu, uFlags, pt.x, pt.y, 0, hWnd, NULL); | |
269 | + break; | |
270 | + } | |
271 | +} | |
272 | + | |
273 | +// | |
274 | +// vSettingDialog() | |
275 | +// | |
276 | +VOID vSettingDialog(HWND hWnd) | |
277 | +{ | |
278 | + if (hSettingDlg != NULL) { | |
279 | + SetForegroundWindow(hSettingDlg); | |
280 | + return; | |
281 | + } | |
282 | + DialogBox(Resource->hLoad(), MAKEINTRESOURCE(IDD_SETTING), hWnd, SettingDlg); | |
283 | +} | |
284 | + | |
285 | +// | |
286 | +// SettingDlg() | |
287 | +// | |
288 | +static INT_PTR CALLBACK SettingDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | |
289 | +{ | |
290 | + UNREFERENCED_PARAMETER(lParam); | |
291 | + switch (message) { | |
292 | + case WM_INITDIALOG: | |
293 | + hSettingDlg = hDlg; | |
294 | + { | |
295 | + HICON hIcon = (HICON)LoadImage(Resource->hLoad(), MAKEINTRESOURCE(IDI_SMALL), IMAGE_ICON, 16, 16, 0); | |
296 | + bInitDlgCenter(hDlg, hIcon, (ICC_BAR_CLASSES | ICC_HOTKEY_CLASS)); | |
297 | + } | |
298 | + { | |
299 | + TCHAR lpText[MAX_LOADSTRING]; | |
300 | + if (LoadString(Resource->hLoad(), IDS_CMBX_LIST01, lpText, MAX_LOADSTRING) == 0) return (INT_PTR)FALSE; | |
301 | + SendDlgItemMessage(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)lpText); | |
302 | + if (LoadString(Resource->hLoad(), IDS_CMBX_LIST02, lpText, MAX_LOADSTRING) == 0) return (INT_PTR)FALSE; | |
303 | + SendDlgItemMessage(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)lpText); | |
304 | + } | |
305 | + { | |
306 | + bSetCheckDlgButton(hDlg, IDC_CHECK1, Profile->lpstAppRegData->bDisplayIMEModeOnCursor); | |
307 | + bSetCheckDlgButton(hDlg, IDC_CHECK2, Profile->lpstAppRegData->bOffChangedFocus); | |
308 | + bSetCheckDlgButton(hDlg, IDC_CHECK3, Profile->lpstAppRegData->bForceHiragana); | |
309 | + bSetCheckDlgButton(hDlg, IDC_CHECK4, Profile->lpstAppRegData->bDoModeDispByIMEKeyDown); | |
310 | + bSetCheckDlgButton(hDlg, IDC_CHECK5, Profile->lpstAppRegData->bDoModeDispByMouseBttnUp); | |
311 | + bSetCheckDlgButton(hDlg, IDC_CHECK6, Profile->lpstAppRegData->bDoModeDispByCtrlUp); | |
312 | + bSetCheckDlgButton(hDlg, IDC_CHECK7, Profile->lpstAppRegData->bDrawNearCaret); | |
313 | + bSetCheckDlgButton(hDlg, IDC_CHECK8, Profile->lpstAppRegData->bEnableEPHelper); | |
314 | + } | |
315 | + { | |
316 | + vSetTrackbar(hDlg, IDC_SLIDER1, 16, 64, 8, Profile->lpstAppRegData->iCursorSize, 8); | |
317 | + vSetTrackbar(hDlg, IDC_SLIDER2, 8, 64, 8, Profile->lpstAppRegData->iModeSize, 8); | |
318 | + vSetTrackbar(hDlg, IDC_SLIDER3, 100, 800, 70, Profile->lpstAppRegData->dwDisplayModeTime, 70); | |
319 | + vSetTrackbar(hDlg, IDC_SLIDER4, 0, 1000, 100, Profile->lpstAppRegData->dwWaitWaveTime, 100); | |
320 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK3) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0) { | |
321 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
322 | + } | |
323 | + else { | |
324 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
325 | + } | |
326 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK4) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
327 | + else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
328 | + } | |
329 | + { | |
330 | + if (Profile->lpstAppRegData->bDisplayFocusWindowIME) { | |
331 | + SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, 0, 0); | |
332 | + } | |
333 | + else { | |
334 | + SendDlgItemMessage(hDlg, IDC_COMBO1, CB_SETCURSEL, 1, 0); | |
335 | + } | |
336 | + } | |
337 | + SetFocus(GetDlgItem(hDlg, IDC_CHECK1)); | |
338 | + return (INT_PTR)TRUE; | |
339 | + case WM_HSCROLL: | |
340 | + { // Track Bar | |
341 | + if ((GetDlgItem(hDlg, IDC_SLIDER1) == (HWND)lParam) | |
342 | + || (GetDlgItem(hDlg, IDC_SLIDER2) == (HWND)lParam) | |
343 | + || (GetDlgItem(hDlg, IDC_SLIDER3) == (HWND)lParam) | |
344 | + || (GetDlgItem(hDlg, IDC_SLIDER4) == (HWND)lParam)) { | |
345 | + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
346 | + } | |
347 | + } | |
348 | + break; | |
349 | + case WM_CTLCOLORDLG: | |
350 | + return (INT_PTR)GetStockObject(WHITE_BRUSH); | |
351 | + case WM_CTLCOLORSTATIC: | |
352 | + case WM_CTLCOLOREDIT: | |
353 | + SetBkMode(((HDC)wParam), TRANSPARENT); | |
354 | + SetTextColor(((HDC)wParam), RGB(0, 0, 0)); | |
355 | + return (INT_PTR)GetStockObject(WHITE_BRUSH); | |
356 | + case WM_COMMAND: | |
357 | + switch (LOWORD(wParam)) { | |
358 | + case IDC_CHECK4: | |
359 | + case IDC_CHECK5: | |
360 | + case IDC_CHECK6: | |
361 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK5) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK6) == 0) { | |
362 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
363 | + } | |
364 | + else { | |
365 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
366 | + } | |
367 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK6) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
368 | + else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
369 | + [[fallthrough]]; | |
370 | + case IDC_CHECK1: | |
371 | + case IDC_CHECK2: | |
372 | + case IDC_CHECK3: | |
373 | + case IDC_CHECK7: | |
374 | + case IDC_CHECK8: | |
375 | + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
376 | + break; | |
377 | + case IDC_COMBO1: | |
378 | + if (HIWORD(wParam) == CBN_SELCHANGE) { | |
379 | + switch (SendDlgItemMessage(hDlg, IDC_COMBO1, CB_GETCURSEL, 0, 0)) { | |
380 | + case 0: | |
381 | + break; | |
382 | + case 1: | |
383 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK2) != 0) { | |
384 | + } | |
385 | + break; | |
386 | + default: | |
387 | + break; | |
388 | + } | |
389 | + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), TRUE); | |
390 | + } | |
391 | + break; | |
392 | + case IDC_BUTTON1: | |
393 | + SetFocus(GetDlgItem(hDlg, IDC_CHECK1)); | |
394 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK4) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK5) == 0 && IsDlgButtonChecked(hDlg, IDC_CHECK6) == 0) { | |
395 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), FALSE); | |
396 | + } | |
397 | + else { | |
398 | + EnableWindow(GetDlgItem(hDlg, IDC_SLIDER2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SLIDER3), TRUE); | |
399 | + } | |
400 | + if (IsDlgButtonChecked(hDlg, IDC_CHECK6) != 0) EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), TRUE); | |
401 | + else EnableWindow(GetDlgItem(hDlg, IDC_SLIDER4), FALSE); | |
402 | + [[fallthrough]]; // fallthrough is explicit | |
403 | + case IDOK: | |
404 | + Profile->lpstAppRegData->bDisplayIMEModeOnCursor = bGetDlgButtonChecked(hDlg, IDC_CHECK1); | |
405 | + Profile->lpstAppRegData->bOffChangedFocus = bGetDlgButtonChecked(hDlg, IDC_CHECK2); | |
406 | + Profile->lpstAppRegData->bForceHiragana = bGetDlgButtonChecked(hDlg, IDC_CHECK3); | |
407 | + Profile->lpstAppRegData->bDoModeDispByIMEKeyDown = bGetDlgButtonChecked(hDlg, IDC_CHECK4); | |
408 | + Profile->lpstAppRegData->bDoModeDispByMouseBttnUp = bGetDlgButtonChecked(hDlg, IDC_CHECK5); | |
409 | + Profile->lpstAppRegData->bDoModeDispByCtrlUp = bGetDlgButtonChecked(hDlg, IDC_CHECK6); | |
410 | + Profile->lpstAppRegData->bDrawNearCaret = bGetDlgButtonChecked(hDlg, IDC_CHECK7); | |
411 | + Profile->lpstAppRegData->bEnableEPHelper = bGetDlgButtonChecked(hDlg, IDC_CHECK8); | |
412 | + Profile->lpstAppRegData->iCursorSize = (int)dwGetTrackbarPos(hDlg, IDC_SLIDER1); | |
413 | + Profile->lpstAppRegData->iModeSize = (int)dwGetTrackbarPos(hDlg, IDC_SLIDER2); | |
414 | + Profile->lpstAppRegData->dwDisplayModeTime = dwGetTrackbarPos(hDlg, IDC_SLIDER3); | |
415 | + Profile->lpstAppRegData->dwWaitWaveTime = dwGetTrackbarPos(hDlg, IDC_SLIDER4); | |
416 | + switch (SendDlgItemMessage(hDlg, IDC_COMBO1, CB_GETCURSEL, 0, 0)) { | |
417 | + case 0: | |
418 | + Profile->lpstAppRegData->bDisplayFocusWindowIME = TRUE; | |
419 | + break; | |
420 | + case 1: | |
421 | + Profile->lpstAppRegData->bDisplayFocusWindowIME = FALSE; | |
422 | + break; | |
423 | + default: | |
424 | + break; | |
425 | + } | |
426 | + if (Profile != NULL) { | |
427 | + Profile->bSetProfileData(); | |
428 | + } | |
429 | + vStopThreadHookTimer(hMainWnd); | |
430 | + if (!bStartThreadHookTimer(hMainWnd)) { | |
431 | + PostMessage(hMainWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); | |
432 | + return (INT_PTR)FALSE; | |
433 | + } | |
434 | + if (LOWORD(wParam) == IDC_BUTTON1) { | |
435 | + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON1), FALSE); | |
436 | + return (INT_PTR)FALSE; | |
437 | + } | |
438 | + [[fallthrough]]; | |
439 | + case IDCANCEL: | |
440 | + EndDialog(hDlg, LOWORD(wParam)); | |
441 | + if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) hSettingDlg = NULL; | |
442 | + return (INT_PTR)TRUE; | |
443 | + } | |
444 | + } | |
445 | + return (INT_PTR)FALSE; | |
446 | +} | |
447 | + | |
448 | +// | |
449 | +// bInitDlgCenter() | |
450 | +// | |
451 | +static BOOL bInitDlgCenter(HWND hDlg, HICON hIcon, DWORD dwICC) | |
452 | +{ | |
453 | + int cx = GetSystemMetrics(SM_CXSCREEN); | |
454 | + int cy = GetSystemMetrics(SM_CYSCREEN); | |
455 | + RECT rc{}; | |
456 | + GetWindowRect(hDlg, (LPRECT)&rc); | |
457 | + rc.right = rc.right - rc.left + 1; rc.bottom = rc.bottom - rc.top + 1; | |
458 | + rc.left = (cx - rc.right) / 2; rc.top = (cy - rc.bottom) / 2; | |
459 | + MoveWindow(hDlg, rc.left, rc.top, rc.right, rc.bottom, TRUE); | |
460 | + SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); | |
461 | + | |
462 | + INITCOMMONCONTROLSEX stICC{}; | |
463 | + stICC.dwSize = sizeof(INITCOMMONCONTROLSEX); | |
464 | + stICC.dwICC = dwICC; | |
465 | + return InitCommonControlsEx(&stICC); | |
466 | +} | |
467 | + | |
468 | +// | |
469 | +// bSetCheckDlgButton() | |
470 | +// | |
471 | +static BOOL bSetCheckDlgButton(HWND hDlg, int iIDButton, BOOL bCheck) | |
472 | +{ | |
473 | + UINT uCheck = 0; | |
474 | + if (bCheck) uCheck = BST_CHECKED; | |
475 | + else uCheck = BST_UNCHECKED; | |
476 | + if (!CheckDlgButton(hDlg, iIDButton, uCheck)) { | |
477 | + return FALSE; | |
478 | + } | |
479 | + return TRUE; | |
480 | +} | |
481 | + | |
482 | +// | |
483 | +// vSetTrackbar() | |
484 | +// | |
485 | +static VOID vSetTrackbar(HWND hDlg, int iIDTrackbar, int iRangeMin, int iRangeMax, int iTickFreq, int iPos, int iPageSize) | |
486 | +{ | |
487 | + SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETRANGE, TRUE, MAKELPARAM(iRangeMin, iRangeMax)); | |
488 | + SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETTICFREQ, iTickFreq, 0); | |
489 | + SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETPOS, TRUE, iPos); | |
490 | + SendDlgItemMessage(hDlg, iIDTrackbar, TBM_SETPAGESIZE, 0, iPageSize); | |
491 | +} | |
492 | + | |
493 | +// | |
494 | +// bGetDlgButtonChecked() | |
495 | +// | |
496 | +static BOOL bGetDlgButtonChecked(HWND hDlg, int iIDButton) | |
497 | +{ | |
498 | + if (IsDlgButtonChecked(hDlg, iIDButton) == 0) return FALSE; | |
499 | + else return TRUE; | |
500 | +} | |
501 | + | |
502 | +// | |
503 | +// dwGetTrackbarPos() | |
504 | +// | |
505 | +static DWORD dwGetTrackbarPos(HWND hDlg, int iIDTrackbar) | |
506 | +{ | |
507 | + return (DWORD)SendDlgItemMessage(hDlg, iIDTrackbar, TBM_GETPOS, NULL, NULL); | |
508 | +} | |
509 | + | |
510 | +// | |
511 | +// vGetSetProfileData() | |
512 | +// | |
513 | +VOID vGetSetProfileData() | |
514 | +{ | |
515 | + bDisplayIMEModeOnCursor = Profile->lpstAppRegData->bDisplayIMEModeOnCursor; | |
516 | + bOffChangedFocus = Profile->lpstAppRegData->bOffChangedFocus; | |
517 | + bDisplayFocusWindowIME = Profile->lpstAppRegData->bDisplayFocusWindowIME; | |
518 | + bDoModeDispByIMEKeyDown = Profile->lpstAppRegData->bDoModeDispByIMEKeyDown; | |
519 | + bDoModeDispByMouseBttnUp = Profile->lpstAppRegData->bDoModeDispByMouseBttnUp; | |
520 | + bDoModeDispByCtrlUp = Profile->lpstAppRegData->bDoModeDispByCtrlUp; | |
521 | + bDrawNearCaret = Profile->lpstAppRegData->bDrawNearCaret; | |
522 | + bEnableEPHelper = Profile->lpstAppRegData->bEnableEPHelper; | |
523 | + bMoveIMEToolbar = Profile->lpstAppRegData->bMoveIMEToolbar; | |
524 | + bIMEModeForced = Profile->lpstAppRegData->bIMEModeForced; | |
525 | +} | |
526 | + | |
527 | +/* = EOF = */ |
@@ -0,0 +1,37 @@ | ||
1 | +// | |
2 | +// TaskTray.h | |
3 | +// Copyright (C) 2022 JeffyTS | |
4 | +// | |
5 | +// No. Date Name Reason & Document | |
6 | +// -------+-----------+-----------+-------------------------------------------- - | |
7 | +// #0000 2022/03/03 JeffyTS New edit. | |
8 | +// #0001 2023/06/30 JeffyTS Divided from FlushMouseSub.h | |
9 | + | |
10 | +// | |
11 | +// Include | |
12 | +// | |
13 | +#pragma once | |
14 | +#include "pch.h" | |
15 | + | |
16 | +// | |
17 | +// Global Data | |
18 | +// | |
19 | +extern HWND hAboutDlg; | |
20 | +extern HWND hSettingDlg; | |
21 | +extern BOOL bIMEInConverting; | |
22 | + | |
23 | +// | |
24 | +// Global Prototype Define | |
25 | +// | |
26 | +extern BOOL bCreateTaskTrayWindow(HWND hWnd, HICON hIcon, LPCTSTR lpszTitile); | |
27 | +extern BOOL bReCreateTaskTrayWindow(HWND hWnd, UINT message); | |
28 | +extern BOOL bDestroyTaskTrayWindow(HWND hWnd); | |
29 | +extern BOOL bGetTaskTrayWindowRect(HWND hWnd, LPRECT lpRect); | |
30 | +extern void Cls_OnTaskTrayEx(HWND hWnd, UINT id, UINT uMsg); | |
31 | +extern void vMessageBox(HWND hWnd, UINT uID, UINT uType); | |
32 | +extern VOID vAboutDialog(HWND hWnd); | |
33 | +extern VOID vSettingDialog(HWND hWnd); | |
34 | +extern VOID vGetSetProfileData(); | |
35 | + | |
36 | + | |
37 | +/* = EOF = */ | |
\ No newline at end of file |
@@ -1,9 +1,10 @@ | ||
1 | -// FlushMouse32.cpp | |
1 | +// | |
2 | +// FlushMouse32.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/04/06 JeffyTS New edit. | |
7 | +// #0000 2022/04/06 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -45,10 +46,9 @@ static UINT_PTR uCheckProcTimer = NULL; | ||
45 | 46 | // |
46 | 47 | // Local Data |
47 | 48 | // |
48 | -static TCHAR szTitle[MAX_LOADSTRING]{}; // タイトル バーのテキスト | |
49 | -//static TCHAR szWindowClass[]{ CLASS_FLUSHMOUSE32 }; // メイン ウィンドウ クラス名 | |
50 | -static HINSTANCE hInst = NULL; // 現在のインターフェイス | |
51 | -static HWND hParentWnd = NULL; // 親のWindow Handle | |
49 | +static TCHAR szTitle[MAX_LOADSTRING]{}; | |
50 | +static HINSTANCE hInst = NULL; | |
51 | +static HWND hParentWnd = NULL; | |
52 | 52 | |
53 | 53 | // |
54 | 54 | // Global Prototype Define |
@@ -68,6 +68,7 @@ static void Cls_OnDestroy(HWND hWnd); | ||
68 | 68 | // Sub |
69 | 69 | static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DWORD dwTime); |
70 | 70 | static BOOL bReportEvent(DWORD dwEventID, WORD wCategory); |
71 | +static BOOL bCreateProcess(LPCTSTR lpszExecName); | |
71 | 72 | static void vMessageBox(HWND hWnd, UINT uID, UINT uType); |
72 | 73 | |
73 | 74 | // |
@@ -177,7 +178,7 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) | ||
177 | 178 | UNREFERENCED_PARAMETER(nCmdShow); |
178 | 179 | #define WINDOWSTYLE WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL // | WS_VISIBLE // WS_MINIMIZE | WS_SYSMENU |
179 | 180 | hInst = hInstance; // グローバル変数にインスタンス ハンドルを格納する |
180 | - HWND hWnd = NULL; // メインウィンドウのハンドル | |
181 | + HWND hWnd = NULL; // メインウィンドウのハンドル | |
181 | 182 | hWnd = CreateWindowEx( |
182 | 183 | WS_DISABLED, // Disabled Window |
183 | 184 | CLASS_FLUSHMOUSE32, // RegisterClass()呼び出しを参照 |
@@ -223,7 +224,7 @@ static BOOL Cls_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) | ||
223 | 224 | return FALSE; |
224 | 225 | } |
225 | 226 | |
226 | - BOOL bBool = FALSE; | |
227 | + BOOL bBool = FALSE; | |
227 | 228 | if (SetUserObjectInformation(GetCurrentProcess(), UOI_TIMERPROC_EXCEPTION_SUPPRESSION, &bBool, sizeof(BOOL)) != FALSE) { |
228 | 229 | // Set Timer for Proc |
229 | 230 | if (uCheckProcTimer == NULL) { |
@@ -281,14 +282,13 @@ static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DW | ||
281 | 282 | } |
282 | 283 | catch (BOOL bRet) { |
283 | 284 | if (!bRet) { |
284 | - return; | |
285 | 285 | } |
286 | 286 | } |
287 | 287 | catch (...) { |
288 | - return; | |
289 | 288 | } |
290 | 289 | bReportEvent(MSG_DETECT_FLUSHMOUSE_STOP, APPLICATION32_CATEGORY); |
291 | - bReportEvent(MSG_RESTART_EVENT, APPLICATION32_CATEGORY); | |
290 | + bCreateProcess(FLUSHMOUSE_EXE); | |
291 | + bReportEvent(MSG_RESTART_EVENT, APPLICATION32_CATEGORY); | |
292 | 292 | PostMessage(hWnd, WM_DESTROY, (WPARAM)NULL, (LPARAM)NULL); |
293 | 293 | } |
294 | 294 | } |
@@ -300,7 +300,7 @@ static VOID CALLBACK vCheckProcTimerProc(HWND hWnd, UINT uMsg, UINT uTimerID, DW | ||
300 | 300 | // |
301 | 301 | static BOOL bReportEvent(DWORD dwEventID, WORD wCategory) |
302 | 302 | { |
303 | - BOOL bRet = FALSE; | |
303 | + BOOL bRet = FALSE; | |
304 | 304 | HANDLE hEvent = RegisterEventSource(NULL, _T("FlushMouse")); |
305 | 305 | if (hEvent != NULL) { |
306 | 306 | if (ReportEvent(hEvent, (0x0000000c & (dwEventID >> 28)), wCategory, dwEventID, NULL, 0, 0, NULL, NULL) != 0) { |
@@ -316,6 +316,30 @@ static BOOL bReportEvent(DWORD dwEventID, WORD wCategory) | ||
316 | 316 | } |
317 | 317 | |
318 | 318 | // |
319 | +// bCreateProcess() | |
320 | +// | |
321 | +static BOOL bCreateProcess(LPCTSTR lpszExecName) | |
322 | +{ | |
323 | + BOOL bRet = FALSE; | |
324 | + DWORD dwSize = 0; | |
325 | + dwSize = ExpandEnvironmentStrings(lpszExecName, NULL, 0); | |
326 | + LPTSTR lpszBuffer = new TCHAR[dwSize]; | |
327 | + if (lpszBuffer) { | |
328 | + ZeroMemory(lpszBuffer, dwSize); | |
329 | + dwSize = ExpandEnvironmentStrings(lpszExecName, lpszBuffer, dwSize); | |
330 | + PROCESS_INFORMATION ProcessInfomation{}; | |
331 | + STARTUPINFO StartupInfo{}; StartupInfo.cb = sizeof(STARTUPINFO); | |
332 | + if (CreateProcess(lpszBuffer, NULL, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &StartupInfo, &ProcessInfomation) != FALSE) { | |
333 | + CloseHandle(ProcessInfomation.hProcess); | |
334 | + CloseHandle(ProcessInfomation.hThread); | |
335 | + bRet = TRUE; | |
336 | + } | |
337 | + delete[] lpszBuffer; | |
338 | + } | |
339 | + return bRet; | |
340 | +} | |
341 | + | |
342 | +// | |
319 | 343 | // vMessageBox() |
320 | 344 | // |
321 | 345 | static void vMessageBox(HWND hWnd, UINT uID, UINT uType) |
@@ -1,9 +1,10 @@ | ||
1 | -// FlushMouse32.h | |
1 | +// | |
2 | +// FlushMouse32.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/04/06 JeffyTS New edit. | |
7 | +// #0000 2022/04/06 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -1,4 +1,5 @@ | ||
1 | -// FlushMouseCursor.cpp | |
1 | +// | |
2 | +// FlushMouseCursor.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
@@ -1,9 +1,10 @@ | ||
1 | -// FlushMouseCursor.h | |
1 | +// | |
2 | +// FlushMouseCursor.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/03/17 JeffyTS New edit. | |
7 | +// #0000 2022/03/17 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -1,3 +1,4 @@ | ||
1 | +// | |
1 | 2 | // Eventlog.mc |
2 | 3 | // Copyright (C) 2023 JeffyTS |
3 | 4 | // |
@@ -108,13 +109,13 @@ | ||
108 | 109 | #define POWERNOTIFICATION_CATEGORY ((DWORD)0x00000010L) |
109 | 110 | |
110 | 111 | // |
111 | -// MessageId: TASKSCHDULER_CATEGORY | |
112 | +// MessageId: TASKSCHEDULER_CATEGORY | |
112 | 113 | // |
113 | 114 | // MessageText: |
114 | 115 | // |
115 | -// TaskSheduler Events | |
116 | +// TaskScheduler Events | |
116 | 117 | // |
117 | -#define TASKSCHDULER_CATEGORY ((DWORD)0x00000011L) | |
118 | +#define TASKSCHEDULER_CATEGORY ((DWORD)0x00000011L) | |
118 | 119 | |
119 | 120 | // |
120 | 121 | // Message definitions. |
@@ -259,7 +260,7 @@ | ||
259 | 260 | // |
260 | 261 | // MessageText: |
261 | 262 | // |
262 | -// Resumeed from Susped (APM). | |
263 | +// Resumed from Suspend (APM). | |
263 | 264 | // |
264 | 265 | #define MSG_PBT_APMRESUMESUSPEND ((DWORD)0x40000102L) |
265 | 266 |
@@ -1,3 +1,4 @@ | ||
1 | +;// | |
1 | 2 | ;// Eventlog.mc |
2 | 3 | ;// Copyright (C) 2023 JeffyTS |
3 | 4 | ;// |
@@ -89,13 +90,13 @@ PowerNotification Events | ||
89 | 90 | . |
90 | 91 | |
91 | 92 | MessageId=0x11 |
92 | -SymbolicName=TASKSCHDULER_CATEGORY | |
93 | +SymbolicName=TASKSCHEDULER_CATEGORY | |
93 | 94 | Language=English |
94 | -TaskSheduler Events | |
95 | +TaskScheduler Events | |
95 | 96 | . |
96 | 97 | |
97 | 98 | Language=Japanese |
98 | -TaskSheduler Events | |
99 | +TaskScheduler Events | |
99 | 100 | . |
100 | 101 | |
101 | 102 |
@@ -291,11 +292,11 @@ Severity=Informational | ||
291 | 292 | Facility=Application |
292 | 293 | SymbolicName=MSG_PBT_APMRESUMESUSPEND |
293 | 294 | Language=English |
294 | -Resumeed from Susped (APM). | |
295 | +Resumed from Suspend (APM). | |
295 | 296 | . |
296 | 297 | |
297 | 298 | Language=Japanese |
298 | -Resumeed from Susped (APM). | |
299 | +Resumed from Suspend (APM). | |
299 | 300 | . |
300 | 301 | |
301 | 302 | MessageId=0x0103 |
@@ -18,7 +18,7 @@ | ||
18 | 18 | // |
19 | 19 | DLLEXPORT BOOL __stdcall bReportEvent(DWORD dwEventID, WORD wCategory) |
20 | 20 | { |
21 | - BOOL bRet = FALSE; | |
21 | + BOOL bRet = FALSE; | |
22 | 22 | HANDLE hEvent = RegisterEventSource(NULL, _T("FlushMouse")); |
23 | 23 | if (hEvent != NULL) { |
24 | 24 | if (ReportEvent(hEvent, (0x0000000c & (dwEventID >> 28)), wCategory, dwEventID, NULL, 0, 0, NULL, NULL) != 0) { |
@@ -1,9 +1,10 @@ | ||
1 | -// FlushMouseDll.cpp : DLL アプリケーションのエントリ ポイントを定義します。 | |
1 | +// | |
2 | +// FlushMouseDll.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/02/12 JeffyTS New edit. | |
7 | +// #0000 2022/02/12 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -1,4 +1,5 @@ | ||
1 | -// FlushMouseDll.h | |
1 | +// | |
2 | +// FlushMouseDll.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
@@ -1,4 +1,5 @@ | ||
1 | -// GlobalHookDll.cpp | |
1 | +// | |
2 | +// GlobalHookDll.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
@@ -77,7 +78,7 @@ DLLEXPORT BOOL __stdcall bGlobalHookSet(HWND hWnd) | ||
77 | 78 | // |
78 | 79 | DLLEXPORT BOOL __stdcall bGlobalHookUnset() |
79 | 80 | { |
80 | - BOOL bRet = FALSE; | |
81 | + BOOL bRet = FALSE; | |
81 | 82 | if (CSharedMem != NULL) { |
82 | 83 | if ((lpDatGlobal = (LPGLOBAL_SHAREDMEM)CSharedMem->lpvSharedMemoryRead()) != NULL) { |
83 | 84 | if (lpDatGlobal->hWnd) { |
@@ -1,4 +1,5 @@ | ||
1 | -// GlobalHookDll.h | |
1 | +// | |
2 | +// GlobalHookDll.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
@@ -1,9 +1,10 @@ | ||
1 | -// KeyboardHookDll.cpp | |
1 | +// | |
2 | +// KeyboardHookDll.cpp | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2022/02/12 JeffyTS New edit. | |
7 | +// #0000 2022/02/12 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | // |
@@ -26,12 +27,12 @@ | ||
26 | 27 | #pragma comment(linker, "/SECTION:FLUSHMOUSEDLL_SEG,RWS") |
27 | 28 | #pragma data_seg("FLUSHMOUSEDLL_SEG") |
28 | 29 | static BOOL bOnlyCtrlLL = FALSE; |
29 | -static DWORD dwPreviousVKLL = 0; | |
30 | +static DWORD dwPreviousVKLL = 0; | |
30 | 31 | static HWND hWndKBParentLL = NULL; |
31 | 32 | static LPKEYBOARDLL_SHAREDMEM lpDatKeyboardLL = NULL; |
32 | 33 | static BOOL bEnableEPHelperLL = FALSE; |
33 | 34 | static BOOL bStartConvertingLL = FALSE; |
34 | -static CSharedMemory *CSharedMemLL = NULL; | |
35 | +static CSharedMemory *CSharedMemLL = NULL; | |
35 | 36 | #pragma data_seg() |
36 | 37 | |
37 | 38 | // |
@@ -78,7 +79,7 @@ DLLEXPORT BOOL __stdcall bKeyboardHookLLSet(HWND hWnd) | ||
78 | 79 | // |
79 | 80 | DLLEXPORT BOOL __stdcall bKeyboardHookLLUnset() |
80 | 81 | { |
81 | - BOOL bRet = FALSE; | |
82 | + BOOL bRet = FALSE; | |
82 | 83 | if (CSharedMemLL != NULL) { |
83 | 84 | if ((lpDatKeyboardLL = (LPKEYBOARDLL_SHAREDMEM)CSharedMemLL->lpvSharedMemoryRead()) != NULL) { |
84 | 85 | if (lpDatKeyboardLL->hHook) { |
@@ -103,7 +104,7 @@ DLLEXPORT BOOL __stdcall bKeyboardHookLLUnset() | ||
103 | 104 | // |
104 | 105 | DLLEXPORT BOOL __stdcall bSetEnableEPHelperLL64(BOOL bEPHelper) |
105 | 106 | { |
106 | - BOOL bRet = FALSE; | |
107 | + BOOL bRet = FALSE; | |
107 | 108 | bEnableEPHelperLL = bEPHelper; |
108 | 109 | if (CSharedMemLL != NULL) { |
109 | 110 | if ((lpDatKeyboardLL = (LPKEYBOARDLL_SHAREDMEM)CSharedMemLL->lpvSharedMemoryRead()) != NULL) { |
@@ -362,23 +363,8 @@ static BOOL bKeyboardHookLLProcSub() | ||
362 | 363 | } |
363 | 364 | } |
364 | 365 | hWndKBParentLL = lpDatKeyboardLL->hWnd; |
365 | - bEnableEPHelperLL = lpDatKeyboardLL->bEnableEPHelper; // @@@ for Explorer Patcher Simple Window Switcher | |
366 | + bEnableEPHelperLL = lpDatKeyboardLL->bEnableEPHelper; | |
366 | 367 | return TRUE; |
367 | - /* | |
368 | - if ((hWndKBParentLL == NULL) || (lpDatKeyboardLL == NULL)) { | |
369 | - if (lpDatKeyboardLL == NULL) { | |
370 | - if ((lpDatKeyboardLL = (LPKEYBOARDLL_SHAREDMEM)lpvSharedMemoryOpen(KEYBOARDHOOKLLMEM, sizeof(KEYBOARDLL_SHAREDMEM))) == NULL) { | |
371 | - return FALSE; | |
372 | - } | |
373 | - } | |
374 | - if (lpDatKeyboardLL->hWnd == NULL) { | |
375 | - return FALSE; | |
376 | - } | |
377 | - hWndKBParentLL = lpDatKeyboardLL->hWnd; | |
378 | - bEnableEPHelperLL = lpDatKeyboardLL->bEnableEPHelper; // @@@ for Explorer Patcher Simple Window Switcher | |
379 | - } | |
380 | - return TRUE; | |
381 | - */ | |
382 | 368 | } |
383 | 369 | |
384 | 370 | /* = EOF = */ |
\ No newline at end of file |
@@ -1,4 +1,5 @@ | ||
1 | -// KeyboardHookDll.h | |
1 | +// | |
2 | +// KeyboardHookDll.h | |
2 | 3 | // Copyright (C) 2022 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
@@ -66,7 +66,7 @@ DLLEXPORT BOOL __stdcall bMouseHookSet32(HWND hWnd) | ||
66 | 66 | // |
67 | 67 | DLLEXPORT BOOL __stdcall bMouseHookUnset32() |
68 | 68 | { |
69 | - BOOL bRet = FALSE; | |
69 | + BOOL bRet = FALSE; | |
70 | 70 | if (CSharedMem != NULL) { |
71 | 71 | if ((lpDatMouse = (LPMOUSE_SHAREDMEM32)CSharedMem->lpvSharedMemoryRead()) != NULL) { |
72 | 72 | if (lpDatMouse->hHook) { |
@@ -0,0 +1,16 @@ | ||
1 | + | |
2 | +# FlushMouse ![Icon](https://osdn.net/users/jeffyts/pf/FlushMouse/wiki/FrontPage/thumb/48x48/FlushMouse.png) | |
3 | + | |
4 | +**タスクトレイに常駐して、マウスカーソルへIMEモードの表示をするユーティリティです** | |
5 | + | |
6 | +**FlushMouse is a software developed by JeffyTS. It is a mouse gesture tool that allows you to perform various operations by drawing gestures with your mouse. (by Bing)** | |
7 | + | |
8 | + | |
9 | + | |
10 | + | |
11 | +使い方については [OSDN/FlushMouse](https://osdn.net/users/jeffyts/pf/FlushMouse/wiki/FrontPage "https://osdn.net/users/JeffyTS/pf/FlushMouse/wiki/FrontPage)") を参照してください (どちらにも同じソースとバイナリが置いてあります) | |
12 | + | |
13 | +![Cursors](https://osdn.net/users/jeffyts/pf/FlushMouse/wiki/FrontPage/thumb/230x181/Cursors.png) | |
14 | + | |
15 | +![SettingDialog](https://osdn.net/users/jeffyts/pf/FlushMouse/wiki/FrontPage/thumb/572x645/SettingDlg.png) | |
16 | + |
@@ -5,12 +5,11 @@ | ||
5 | 5 | ||[[Thumb(FlushMouse.png, size=48x48)]]||'''[[ProjectDescription]](タスクトレイに常駐して、マウスカーソルへIMEモードの表示をするユーティリティです)[[BR]]FlushMouse is a software developed by JeffyTS . It is a mouse gesture tool that allows you to perform various operations by drawing gestures with your mouse . (by Bing)'''|| |
6 | 6 | |
7 | 7 | [[BR]] |
8 | -2023/06/28[[BR]] | |
9 | - '''Version 1.1.0.3 をリリースしました'''[[BR]] | |
8 | +2023/07/05[[BR]] | |
9 | + '''Version 1.1.1.7 をリリースしました'''[[BR]] | |
10 | 10 | [[BR]] |
11 | 11 | (主な変更点)[[BR]] |
12 | - * キャレット位置の取得方法を見直しました。これで、Chromium Edge や Chrome など多数のアプリでキャレットの左側に IME のモードを表示できるようになりました[[BR]] | |
13 | - * その他、細かい処理の見直しや、バグの修正をしました[[BR]] | |
12 | + * 細かい処理の見直しや、バグの修正をしました[[BR]] | |
14 | 13 | [[BR]] |
15 | 14 | * IMEモードの表示の色指定でαチャネルが有効になるようにしてあります(設定画面は作成していません。レジストリを編集できる方は好みの色にしてみてください (ただし、レジストリの編集は十分注意して行ってください)[[BR]] |
16 | 15 | * HKEY_CURRENT_USER\Software\JeffyTS\FlushMouse の NearDrawCaretColor と NearDrawMouseColor です。上位バイトから、α B G R の順です[[BR]] |
@@ -1,18 +1,19 @@ | ||
1 | +// | |
1 | 2 | // version.h |
2 | 3 | // Copyright (C) 2023 JeffyTS |
3 | 4 | // |
4 | 5 | // No. Date Name Reason & Document |
5 | 6 | // -------+-----------+-----------+-------------------------------------------- - |
6 | -// #0000 2023/03/17 JeffyTS New edit. | |
7 | +// #0000 2023/03/17 JeffyTS New edit. | |
7 | 8 | // |
8 | 9 | |
9 | 10 | #define MAJOR_VERSION 1 |
10 | 11 | #define MINOR_VERSION 1 |
11 | -#define BUILD_VERSION 0 | |
12 | -#define REVISON_VERSION 3 | |
12 | +#define BUILD_VERSION 1 | |
13 | +#define REVISON_VERSION 7 | |
13 | 14 | |
14 | -#define FILE_VERSION_STRING VALUE "FileVersion", "1.1.0.3" | |
15 | -#define PRODUCT_VERSION_STRING VALUE "ProductVersion", "1.1.0.3" | |
15 | +#define FILE_VERSION_STRING VALUE "FileVersion", "1.1.1.7" | |
16 | +#define PRODUCT_VERSION_STRING VALUE "ProductVersion", "1.1.1.7" | |
16 | 17 | |
17 | 18 | #define FILE_VERSION MAJOR_VERSION, MINOR_VERSION, BUILD_VERSION, REVISON_VERSION |
18 | 19 | #define PRODUCT_VERSION MAJOR_VERSION, MINOR_VERSION, BUILD_VERSION, REVISON_VERSION |
@@ -1,5 +1,6 @@ | ||
1 | 1 | <Include> |
2 | 2 | <!-- for wix Setup Project --> |
3 | - <?define Version = "1.0.2.6" ?> | |
3 | + <!-- Copyright (C) 2023 JeffyTS --> | |
4 | + <?define Version = "1.1.1.7" ?> | |
4 | 5 | </Include> |
5 | 6 |