• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision8546 (tree)
Zeit2020-02-19 01:50:50
Autorzmatsuo

Log Message

ブロードキャストダイアログの文字化けを修正

- dlglib_cpp.cpp内の不要コードを削除
- layer_for_unicode にダイアログボックス系を追加

- _CreateDialogIndirectParamW()
- _DialogBoxIndirectParamW()

Ändern Zusammenfassung

Diff

--- trunk/teraterm/common/compat_win.cpp (revision 8545)
+++ trunk/teraterm/common/compat_win.cpp (revision 8546)
@@ -64,6 +64,9 @@
6464 HWND (WINAPI *pGetConsoleWindow)(void);
6565 int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
6666 INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
67+HWND (WINAPI *pCreateDialogIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
68+ HWND hWndParent, DLGPROC lpDialogFunc,
69+ LPARAM dwInitParam);
6770
6871 // gdi32.lib
6972 int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res);
@@ -151,6 +154,7 @@
151154 { "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW },
152155 { "MessageBoxW", (void **)&pMessageBoxW },
153156 { "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW },
157+ { "CreateDialogIndirectParamW", (void **)&pCreateDialogIndirectParamW },
154158 { "InsertMenuW", (void **)&pInsertMenuW },
155159 { "AppendMenuW", (void **)&pAppendMenuW },
156160 { "SendMessageW", (void **)&pSendMessageW },
@@ -244,6 +248,7 @@
244248 pSetDlgItemTextW = NULL;
245249 pGetDlgItemTextW = NULL;
246250 pDialogBoxIndirectParamW = NULL;
251+ pCreateDialogIndirectParamW = NULL;
247252 pCreateWindowExW = NULL;
248253 pRegisterClassW = NULL;
249254 pDefWindowProcW = NULL;
--- trunk/teraterm/common/compat_win.h (revision 8545)
+++ trunk/teraterm/common/compat_win.h (revision 8546)
@@ -99,6 +99,9 @@
9999 extern HWND (WINAPI *pGetConsoleWindow)(void);
100100 extern int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
101101 extern INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
102+extern HWND (WINAPI *pCreateDialogIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
103+ HWND hWndParent, DLGPROC lpDialogFunc,
104+ LPARAM dwInitParam);
102105 extern HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData);
103106 extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
104107 extern BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
--- trunk/teraterm/common/dlglib_cpp.cpp (revision 8545)
+++ trunk/teraterm/common/dlglib_cpp.cpp (revision 8546)
@@ -37,130 +37,14 @@
3737
3838 #include "dlglib.h"
3939 #include "ttlib.h"
40+#include "layer_for_unicode.h"
4041
41-// ダイアログモーダル状態の時、OnIdle()を実行する
42-//#define ENABLE_CALL_IDLE_MODAL 1
43-
44-extern BOOL CallOnIdle(LONG lCount);
45-
46-typedef struct {
47- DLGPROC OrigProc; // Dialog proc
48- LONG_PTR OrigUser; // DWLP_USER
49- LPARAM ParamInit;
50- int DlgResult;
51- bool EndDialogFlag;
52-} TTDialogData;
53-
54-static TTDialogData *TTDialogTmpData;
55-
56-#if ENABLE_CALL_IDLE_MODAL
57-static int TTDoModal(HWND hDlgWnd)
58-{
59- LONG lIdleCount = 0;
60- MSG Msg;
61- TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
62-
63- for (;;)
64- {
65- if (!IsWindow(hDlgWnd)) {
66- // ウインドウが閉じられた
67- return IDCANCEL;
68- }
69-#if defined(_DEBUG)
70- if (!IsWindowVisible(hDlgWnd)) {
71- // 誤ってEndDialog()が使われた? -> TTEndDialog()を使うこと
72- ::ShowWindow(hDlgWnd, SW_SHOWNORMAL);
73- }
74-#endif
75- if (data->EndDialogFlag) {
76- // TTEndDialog()が呼ばれた
77- return data->DlgResult;
78- }
79-
80- if(!::PeekMessage(&Msg, NULL, NULL, NULL, PM_NOREMOVE))
81- {
82- // メッセージがない
83- // OnIdel() を処理する
84- if (!CallOnIdle(lIdleCount++)) {
85- // Idle処理がなくなった
86- lIdleCount = 0;
87- Sleep(10);
88- }
89- continue;
90- }
91- else
92- {
93- // メッセージがある
94-
95- // pump message
96- BOOL quit = !::GetMessage(&Msg, NULL, NULL, NULL);
97- if (quit) {
98- // QM_QUIT
99- PostQuitMessage(0);
100- return IDCANCEL;
101- }
102-
103- if (!::IsDialogMessage(hDlgWnd, &Msg)) {
104- // ダイアログ以外の処理
105- ::TranslateMessage(&Msg);
106- ::DispatchMessage(&Msg);
107- }
108- }
109- }
110-
111- // ここには来ない
112- return IDOK;
113-}
114-#endif
115-
116-static INT_PTR CALLBACK TTDialogProc(
117- HWND hDlgWnd, UINT msg,
118- WPARAM wParam, LPARAM lParam)
119-{
120- TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
121- if (msg == WM_INITDIALOG) {
122- data = (TTDialogData *)lParam;
123- SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)lParam);
124- lParam = data->ParamInit;
125- }
126-
127- if (data == NULL) {
128- // WM_INITDIALOGよりも前は設定されていない
129- data = TTDialogTmpData;
130- } else {
131- // TTEndDialog()が呼ばれたとき、DWLP_USER が参照できない
132- TTDialogTmpData = data;
133- }
134-
135- SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)data->OrigProc);
136- SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data->OrigUser);
137- LRESULT Result = data->OrigProc(hDlgWnd, msg, wParam, lParam);
138- data->OrigProc = (DLGPROC)GetWindowLongPtr(hDlgWnd, DWLP_DLGPROC);
139- data->OrigUser = GetWindowLongPtr(hDlgWnd, DWLP_USER);
140- SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)TTDialogProc);
141- SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
142-
143- if (msg == WM_NCDESTROY) {
144- SetWindowLongPtr(hDlgWnd, DWLP_USER, 0);
145- free(data);
146- }
147-
148- return Result;
149-}
150-
15142 /**
15243 * EndDialog() 互換関数
15344 */
15445 BOOL TTEndDialog(HWND hDlgWnd, INT_PTR nResult)
15546 {
156-#if ENABLE_CALL_IDLE_MODAL
157- TTDialogData *data = TTDialogTmpData;
158- data->DlgResult = nResult;
159- data->EndDialogFlag = true;
160- return TRUE;
161-#else
16247 return EndDialog(hDlgWnd, nResult);
163-#endif
16448 }
16549
16650 /**
@@ -173,19 +57,8 @@
17357 DLGPROC lpDialogFunc, // ダイアログボックスプロシージャへのポインタ
17458 LPARAM lParamInit) // 初期化値
17559 {
176- TTDialogData *data = (TTDialogData *)malloc(sizeof(TTDialogData));
177- data->OrigProc = lpDialogFunc;
178- data->OrigUser = 0;
179- data->ParamInit = lParamInit;
180- data->EndDialogFlag = false;
181- data->DlgResult = 0;
18260 DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName);
183- TTDialogTmpData = data;
184- HWND hDlgWnd = CreateDialogIndirectParam(
185- hInstance, lpTemplate, hWndParent, TTDialogProc, (LPARAM)data);
186- TTDialogTmpData = NULL;
187- ShowWindow(hDlgWnd, SW_SHOW);
188- UpdateWindow(hDlgWnd);
61+ HWND hDlgWnd = _CreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit);
18962 free(lpTemplate);
19063 return hDlgWnd;
19164 }
@@ -207,63 +80,24 @@
20780 * DialogBoxParam() 互換関数
20881 * EndDialog()ではなく、TTEndDialog()を使用すること
20982 */
210-INT_PTR TTDialogBoxParam(
211- HINSTANCE hInstance,
212- LPCTSTR lpTemplateName,
213- HWND hWndParent, // オーナーウィンドウのハンドル
214- DLGPROC lpDialogFunc, // ダイアログボックスプロシージャへのポインタ
215- LPARAM lParamInit) // 初期化値
83+INT_PTR TTDialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplateName,
84+ HWND hWndParent, // オーナーウィンドウのハンドル
85+ DLGPROC lpDialogFunc, // ダイアログボックスプロシージャへのポインタ
86+ LPARAM lParamInit) // 初期化値
21687 {
217-#if ENABLE_CALL_IDLE_MODAL
218- HWND hDlgWnd = TTCreateDialogIndirectParam(
219- hInstance, lpTemplateName,
220- hWndParent, lpDialogFunc, lParamInit);
221- EnableWindow(hWndParent, FALSE);
222- int DlgResult = TTDoModal(hDlgWnd);
223- ::DestroyWindow(hDlgWnd);
224- EnableWindow(hWndParent, TRUE);
225- return DlgResult;
226-#else
22788 DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName);
228- INT_PTR DlgResult;
229- static INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
230-
231- // 注 9xでは DialogBoxIndirectParamW を使用しない
232- // DialogBoxIndirectParamW は存在しても常に失敗する
233- if (IsWindowsNTKernel() && pDialogBoxIndirectParamW == NULL) {
234- HMODULE hDll = LoadLibrary("user32.dll");
235- FARPROC *proc = (FARPROC *)&pDialogBoxIndirectParamW;
236- *proc = GetProcAddress(hDll, "DialogBoxIndirectParamW");
237- }
238-
239- if (pDialogBoxIndirectParamW == NULL) {
240- DlgResult = DialogBoxIndirectParamA(
241- hInstance, lpTemplate, hWndParent,
242- lpDialogFunc, lParamInit);
243- }
244- else {
245- DlgResult = pDialogBoxIndirectParamW(
246- hInstance, lpTemplate, hWndParent,
247- lpDialogFunc, lParamInit);
248- }
89+ INT_PTR DlgResult = _DialogBoxIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit);
24990 free(lpTemplate);
25091 return DlgResult;
251-#endif
25292 }
25393
25494 /**
255- * DialogBoxParam() 互換関数
95+ * DialogBox() 互換関数
25696 * EndDialog()ではなく、TTEndDialog()を使用すること
25797 */
258-INT_PTR TTDialogBox(
259- HINSTANCE hInstance,
260- LPCTSTR lpTemplateName,
261- HWND hWndParent,
262- DLGPROC lpDialogFunc)
98+INT_PTR TTDialogBox(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc)
26399 {
264- return TTDialogBoxParam(
265- hInstance, lpTemplateName,
266- hWndParent, lpDialogFunc, (LPARAM)NULL);
100+ return TTDialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc, NULL);
267101 }
268102
269103 /**
--- trunk/teraterm/common/layer_for_unicode.cpp (revision 8545)
+++ trunk/teraterm/common/layer_for_unicode.cpp (revision 8546)
@@ -499,3 +499,21 @@
499499 BOOL r = Shell_NotifyIconA(dwMessage, (PNOTIFYICONDATAA)p);
500500 return r;
501501 }
502+
503+HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
504+ LPARAM dwInitParam)
505+{
506+ if (pCreateDialogIndirectParamW != NULL) {
507+ return pCreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam);
508+ }
509+ return CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam);
510+}
511+
512+INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
513+ DLGPROC lpDialogFunc, LPARAM lParamInit)
514+{
515+ if (pDialogBoxIndirectParamW != NULL) {
516+ return pDialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit);
517+ }
518+ return DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit);
519+}
--- trunk/teraterm/common/layer_for_unicode.h (revision 8545)
+++ trunk/teraterm/common/layer_for_unicode.h (revision 8546)
@@ -124,6 +124,12 @@
124124 UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
125125 BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData);
126126
127+HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
128+ HWND hWndParent, DLGPROC lpDialogFunc,
129+ LPARAM dwInitParam);
130+INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
131+ DLGPROC lpDialogFunc, LPARAM lParamInit);
132+
127133 #ifdef __cplusplus
128134 }
129135 #endif
--- trunk/teraterm/teraterm/vtwin.cpp (revision 8545)
+++ trunk/teraterm/teraterm/vtwin.cpp (revision 8546)
@@ -6261,8 +6261,8 @@
62616261 goto activate;
62626262 }
62636263
6264- hDlgWnd = CreateDialog(m_hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG),
6265- HVTWin, (DLGPROC)BroadcastCommandDlgProc);
6264+ hDlgWnd = TTCreateDialog(m_hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG),
6265+ HVTWin, (DLGPROC)BroadcastCommandDlgProc);
62666266
62676267 if (hDlgWnd == NULL) {
62686268 return;
Show on old repository browser