[Ttssh2-commit] [8546] ブロードキャストダイアログの文字化けを修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 2月 19日 (水) 01:50:51 JST


Revision: 8546
          https://osdn.net/projects/ttssh2/scm/svn/commits/8546
Author:   zmatsuo
Date:     2020-02-19 01:50:50 +0900 (Wed, 19 Feb 2020)
Log Message:
-----------
ブロードキャストダイアログの文字化けを修正

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

Modified Paths:
--------------
    trunk/teraterm/common/compat_win.cpp
    trunk/teraterm/common/compat_win.h
    trunk/teraterm/common/dlglib_cpp.cpp
    trunk/teraterm/common/layer_for_unicode.cpp
    trunk/teraterm/common/layer_for_unicode.h
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/compat_win.cpp
===================================================================
--- trunk/teraterm/common/compat_win.cpp	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/common/compat_win.cpp	2020-02-18 16:50:50 UTC (rev 8546)
@@ -64,6 +64,9 @@
 HWND (WINAPI *pGetConsoleWindow)(void);
 int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
 INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
+HWND (WINAPI *pCreateDialogIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
+										   HWND hWndParent, DLGPROC lpDialogFunc,
+										   LPARAM dwInitParam);
 
 // gdi32.lib
 int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res);
@@ -151,6 +154,7 @@
 	{ "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW },
 	{ "MessageBoxW", (void **)&pMessageBoxW },
 	{ "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW },
+	{ "CreateDialogIndirectParamW", (void **)&pCreateDialogIndirectParamW },
 	{ "InsertMenuW", (void **)&pInsertMenuW },
 	{ "AppendMenuW", (void **)&pAppendMenuW },
 	{ "SendMessageW", (void **)&pSendMessageW },
@@ -244,6 +248,7 @@
 		pSetDlgItemTextW = NULL;
 		pGetDlgItemTextW = NULL;
 		pDialogBoxIndirectParamW = NULL;
+		pCreateDialogIndirectParamW = NULL;
 		pCreateWindowExW = NULL;
 		pRegisterClassW = NULL;
 		pDefWindowProcW = NULL;

Modified: trunk/teraterm/common/compat_win.h
===================================================================
--- trunk/teraterm/common/compat_win.h	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/common/compat_win.h	2020-02-18 16:50:50 UTC (rev 8546)
@@ -99,6 +99,9 @@
 extern HWND (WINAPI *pGetConsoleWindow)(void);
 extern int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
 extern INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
+extern HWND (WINAPI *pCreateDialogIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
+												  HWND hWndParent, DLGPROC lpDialogFunc,
+												  LPARAM dwInitParam);
 extern HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData);
 extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
 extern BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);

Modified: trunk/teraterm/common/dlglib_cpp.cpp
===================================================================
--- trunk/teraterm/common/dlglib_cpp.cpp	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/common/dlglib_cpp.cpp	2020-02-18 16:50:50 UTC (rev 8546)
@@ -37,130 +37,14 @@
 
 #include "dlglib.h"
 #include "ttlib.h"
+#include "layer_for_unicode.h"
 
-// \x83_\x83C\x83A\x83\x8D\x83O\x83\x82\x81[\x83_\x83\x8B\x8F\xF3\x91Ԃ̎\x9E\x81AOnIdle()\x82\xF0\x8E\xC0\x8Ds\x82\xB7\x82\xE9
-//#define ENABLE_CALL_IDLE_MODAL	1
-
-extern BOOL CallOnIdle(LONG lCount);
-
-typedef struct {
-	DLGPROC OrigProc;	// Dialog proc
-	LONG_PTR OrigUser;	// DWLP_USER
-	LPARAM ParamInit;
-	int DlgResult;
-	bool EndDialogFlag;
-} TTDialogData;
-
-static TTDialogData *TTDialogTmpData;
-
-#if ENABLE_CALL_IDLE_MODAL
-static int TTDoModal(HWND hDlgWnd)
-{
-	LONG lIdleCount = 0;
-	MSG Msg;
-	TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
-
-	for (;;)
-	{
-		if (!IsWindow(hDlgWnd)) {
-			// \x83E\x83C\x83\x93\x83h\x83E\x82\xAA\x95‚\xB6\x82\xE7\x82ꂽ
-			return IDCANCEL;
-		}
-#if defined(_DEBUG)
-		if (!IsWindowVisible(hDlgWnd)) {
-			// \x8C\xEB\x82\xC1\x82\xC4EndDialog()\x82\xAA\x8Eg\x82\xED\x82ꂽ? -> TTEndDialog()\x82\xF0\x8Eg\x82\xA4\x82\xB1\x82\xC6
-			::ShowWindow(hDlgWnd, SW_SHOWNORMAL);
-		}
-#endif
-		if (data->EndDialogFlag) {
-			// TTEndDialog()\x82\xAA\x8CĂ΂ꂽ
-			return data->DlgResult;
-		}
-
-		if(!::PeekMessage(&Msg, NULL, NULL, NULL, PM_NOREMOVE))
-		{
-			// \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xA2
-			// OnIdel() \x82\xF0\x8F\x88\x97\x9D\x82\xB7\x82\xE9
-			if (!CallOnIdle(lIdleCount++)) {
-				// Idle\x8F\x88\x97\x9D\x82\xAA\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD
-				lIdleCount = 0;
-				Sleep(10);
-			}
-			continue;
-		}
-		else
-		{
-			// \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82\xA0\x82\xE9
-
-			// pump message
-			BOOL quit = !::GetMessage(&Msg, NULL, NULL, NULL);
-			if (quit) {
-				// QM_QUIT
-				PostQuitMessage(0);
-				return IDCANCEL;
-			}
-
-			if (!::IsDialogMessage(hDlgWnd, &Msg)) {
-				// \x83_\x83C\x83A\x83\x8D\x83O\x88ȊO\x82̏\x88\x97\x9D
-				::TranslateMessage(&Msg);
-				::DispatchMessage(&Msg);
-			}
-		}
-	}
-
-	// \x82\xB1\x82\xB1\x82ɂ͗\x88\x82Ȃ\xA2
-	return IDOK;
-}
-#endif
-
-static INT_PTR CALLBACK TTDialogProc(
-	HWND hDlgWnd, UINT msg,
-	WPARAM wParam, LPARAM lParam)
-{
-	TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
-	if (msg == WM_INITDIALOG) {
-		data = (TTDialogData *)lParam;
-		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)lParam);
-		lParam = data->ParamInit;
-	}
-
-	if (data == NULL) {
-		// WM_INITDIALOG\x82\xE6\x82\xE8\x82\xE0\x91O\x82͐ݒ肳\x82\xEA\x82Ă\xA2\x82Ȃ\xA2
-		data = TTDialogTmpData;
-	} else {
-		// TTEndDialog()\x82\xAA\x8CĂ΂ꂽ\x82Ƃ\xAB\x81ADWLP_USER \x82\xAA\x8EQ\x8FƂł\xAB\x82Ȃ\xA2
-		TTDialogTmpData = data;
-	}
-
-	SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)data->OrigProc);
-	SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data->OrigUser);
-	LRESULT Result = data->OrigProc(hDlgWnd, msg, wParam, lParam);
-	data->OrigProc = (DLGPROC)GetWindowLongPtr(hDlgWnd, DWLP_DLGPROC);
-	data->OrigUser = GetWindowLongPtr(hDlgWnd, DWLP_USER);
-	SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)TTDialogProc);
-	SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
-
-	if (msg == WM_NCDESTROY) {
-		SetWindowLongPtr(hDlgWnd, DWLP_USER, 0);
-		free(data);
-	}
-
-	return Result;
-}
-
 /**
  *	EndDialog() \x8C݊\xB7\x8A֐\x94
  */
 BOOL TTEndDialog(HWND hDlgWnd, INT_PTR nResult)
 {
-#if ENABLE_CALL_IDLE_MODAL
-	TTDialogData *data = TTDialogTmpData;
-	data->DlgResult = nResult;
-	data->EndDialogFlag = true;
-	return TRUE;
-#else
 	return EndDialog(hDlgWnd, nResult);
-#endif
 }
 
 /**
@@ -173,19 +57,8 @@
 	DLGPROC lpDialogFunc,		// \x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x83v\x83\x8D\x83V\x81[\x83W\x83\x83\x82ւ̃|\x83C\x83\x93\x83^
 	LPARAM lParamInit)			// \x8F\x89\x8A\xFA\x89\xBB\x92l
 {
-	TTDialogData *data = (TTDialogData *)malloc(sizeof(TTDialogData));
-	data->OrigProc = lpDialogFunc;
-	data->OrigUser = 0;
-	data->ParamInit = lParamInit;
-	data->EndDialogFlag = false;
-	data->DlgResult = 0;
 	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName);
-	TTDialogTmpData = data;
-	HWND hDlgWnd = CreateDialogIndirectParam(
-		hInstance, lpTemplate, hWndParent, TTDialogProc, (LPARAM)data);
-	TTDialogTmpData = NULL;
-	ShowWindow(hDlgWnd, SW_SHOW);
-    UpdateWindow(hDlgWnd);
+	HWND hDlgWnd = _CreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit);
 	free(lpTemplate);
 	return hDlgWnd;
 }
@@ -207,63 +80,24 @@
  *	DialogBoxParam() \x8C݊\xB7\x8A֐\x94
  *		EndDialog()\x82ł͂Ȃ\xAD\x81ATTEndDialog()\x82\xF0\x8Eg\x97p\x82\xB7\x82邱\x82\xC6
  */
-INT_PTR TTDialogBoxParam(
-	HINSTANCE hInstance,
-	LPCTSTR lpTemplateName,
-	HWND hWndParent,			// \x83I\x81[\x83i\x81[\x83E\x83B\x83\x93\x83h\x83E\x82̃n\x83\x93\x83h\x83\x8B
-	DLGPROC lpDialogFunc,		// \x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x83v\x83\x8D\x83V\x81[\x83W\x83\x83\x82ւ̃|\x83C\x83\x93\x83^
-	LPARAM lParamInit)			// \x8F\x89\x8A\xFA\x89\xBB\x92l
+INT_PTR TTDialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplateName,
+						 HWND hWndParent,		// \x83I\x81[\x83i\x81[\x83E\x83B\x83\x93\x83h\x83E\x82̃n\x83\x93\x83h\x83\x8B
+						 DLGPROC lpDialogFunc,  // \x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x83v\x83\x8D\x83V\x81[\x83W\x83\x83\x82ւ̃|\x83C\x83\x93\x83^
+						 LPARAM lParamInit)		// \x8F\x89\x8A\xFA\x89\xBB\x92l
 {
-#if ENABLE_CALL_IDLE_MODAL
-	HWND hDlgWnd = TTCreateDialogIndirectParam(
-		hInstance, lpTemplateName,
-		hWndParent, lpDialogFunc, lParamInit);
-	EnableWindow(hWndParent, FALSE);
-	int DlgResult = TTDoModal(hDlgWnd);
-	::DestroyWindow(hDlgWnd);
-	EnableWindow(hWndParent, TRUE);
-	return DlgResult;
-#else
 	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName);
-	INT_PTR DlgResult;
-	static INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
-
-	// \x92\x8D 9x\x82ł\xCD DialogBoxIndirectParamW \x82\xF0\x8Eg\x97p\x82\xB5\x82Ȃ\xA2
-	//		DialogBoxIndirectParamW \x82͑\xB6\x8D݂\xB5\x82Ă\xE0\x8F\xED\x82Ɏ\xB8\x94s\x82\xB7\x82\xE9
-	if (IsWindowsNTKernel() && pDialogBoxIndirectParamW == NULL) {
-		HMODULE hDll = LoadLibrary("user32.dll");
-		FARPROC *proc = (FARPROC *)&pDialogBoxIndirectParamW;
-		*proc = GetProcAddress(hDll, "DialogBoxIndirectParamW");
-	}
-
-	if (pDialogBoxIndirectParamW == NULL) {
-		DlgResult = DialogBoxIndirectParamA(
-			hInstance, lpTemplate, hWndParent,
-			lpDialogFunc, lParamInit);
-	}
-	else {
-		DlgResult = pDialogBoxIndirectParamW(
-			hInstance, lpTemplate, hWndParent,
-			lpDialogFunc, lParamInit);
-	}
+	INT_PTR DlgResult = _DialogBoxIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit);
 	free(lpTemplate);
 	return DlgResult;
-#endif
 }
 
 /**
- *	DialogBoxParam() \x8C݊\xB7\x8A֐\x94
+ *	DialogBox() \x8C݊\xB7\x8A֐\x94
  *		EndDialog()\x82ł͂Ȃ\xAD\x81ATTEndDialog()\x82\xF0\x8Eg\x97p\x82\xB7\x82邱\x82\xC6
  */
-INT_PTR TTDialogBox(
-	HINSTANCE hInstance,
-	LPCTSTR lpTemplateName,
-	HWND hWndParent,
-	DLGPROC lpDialogFunc)
+INT_PTR TTDialogBox(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc)
 {
-	return TTDialogBoxParam(
-		hInstance, lpTemplateName,
-		hWndParent, lpDialogFunc, (LPARAM)NULL);
+	return TTDialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc, NULL);
 }
 
 /**

Modified: trunk/teraterm/common/layer_for_unicode.cpp
===================================================================
--- trunk/teraterm/common/layer_for_unicode.cpp	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/common/layer_for_unicode.cpp	2020-02-18 16:50:50 UTC (rev 8546)
@@ -499,3 +499,21 @@
 	BOOL r = Shell_NotifyIconA(dwMessage, (PNOTIFYICONDATAA)p);
 	return r;
 }
+
+HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
+								 LPARAM dwInitParam)
+{
+	if (pCreateDialogIndirectParamW != NULL) {
+		return pCreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam);
+	}
+	return CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam);
+}
+
+INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
+								 DLGPROC lpDialogFunc, LPARAM lParamInit)
+{
+	if (pDialogBoxIndirectParamW != NULL) {
+		return pDialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit);
+	}
+	return DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit);
+}

Modified: trunk/teraterm/common/layer_for_unicode.h
===================================================================
--- trunk/teraterm/common/layer_for_unicode.h	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/common/layer_for_unicode.h	2020-02-18 16:50:50 UTC (rev 8546)
@@ -124,6 +124,12 @@
 UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
 BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData);
 
+HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
+								 HWND hWndParent, DLGPROC lpDialogFunc,
+								 LPARAM dwInitParam);
+INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
+								 DLGPROC lpDialogFunc, LPARAM lParamInit);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2020-02-18 16:50:47 UTC (rev 8545)
+++ trunk/teraterm/teraterm/vtwin.cpp	2020-02-18 16:50:50 UTC (rev 8546)
@@ -6261,8 +6261,8 @@
 		goto activate;
 	}
 
-	hDlgWnd = CreateDialog(m_hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG),
-	                       HVTWin, (DLGPROC)BroadcastCommandDlgProc);
+	hDlgWnd = TTCreateDialog(m_hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG),
+							 HVTWin, (DLGPROC)BroadcastCommandDlgProc);
 
 	if (hDlgWnd == NULL) {
 		return;


Ttssh2-commit メーリングリストの案内
Back to archive index