[Ttssh2-commit] [7512] Drag&Dropダイアログを高Dpiに対応

scmno****@osdn***** scmno****@osdn*****
2019年 3月 25日 (月) 23:45:54 JST


Revision: 7512
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7512
Author:   zmatsuo
Date:     2019-03-25 23:45:53 +0900 (Mon, 25 Mar 2019)
Log Message:
-----------
Drag&Dropダイアログを高Dpiに対応
UNICODEを考慮した
WM_NEXTDLGCTL でフォーカスを持つコントロールを直接指定するようにした

Modified Paths:
--------------
    trunk/teraterm/teraterm/dnddlg.cpp
    trunk/teraterm/teraterm/dnddlg.h

-------------- next part --------------
Modified: trunk/teraterm/teraterm/dnddlg.cpp
===================================================================
--- trunk/teraterm/teraterm/dnddlg.cpp	2019-03-25 14:29:54 UTC (rev 7511)
+++ trunk/teraterm/teraterm/dnddlg.cpp	2019-03-25 14:45:53 UTC (rev 7512)
@@ -39,7 +39,7 @@
 #include "dlglib.h"
 
 struct DrapDropDlgParam {
-	const char *TargetFilename;
+	const TCHAR *TargetFilename;
 	enum drop_type DropType;
 	unsigned char DropTypePaste;
 	bool ScpEnable;
@@ -56,23 +56,11 @@
 };
 
 struct DrapDropDlgData {
-	HFONT hNewFont;
 	DrapDropDlgParam *Param;
 };
 
 static LRESULT CALLBACK OnDragDropDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
 {
-	static const int FontIDs[] = {
-		IDC_FILENAME_EDIT,
-		IDC_DAD_STATIC,
-		IDC_SCP_RADIO, IDC_SENDFILE_RADIO, IDC_PASTE_RADIO,
-		IDC_SCP_PATH_LABEL, IDC_SCP_PATH, IDC_SCP_PATH_NOTE,
-		IDC_BINARY_CHECK,
-		IDC_ESCAPE_CHECK, IDC_NEWLINE_RADIO, IDC_SPACE_RADIO,
-		IDC_SAME_PROCESS_CHECK, IDC_SAME_PROCESS_NEXTDROP_CHECK, IDC_DONTSHOW_CHECK,
-		IDC_DAD_NOTE,
-		IDOK, IDCANCEL,
-	};
 	static const DlgTextInfo TextInfos[] = {
 		{ 0, "DLG_DANDD_TITLE" },
 		{ IDC_DAD_STATIC, "DLG_DANDD_TEXT" },
@@ -101,7 +89,6 @@
 		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)DlgData);
 		DrapDropDlgParam *Param = (DrapDropDlgParam *)lp;
 		DlgData->Param = Param;
-		DlgData->hNewFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
 		SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), Param->UILanguageFile);
 
 		// target file
@@ -115,7 +102,7 @@
 						 IDC_SCP_RADIO);
 
 		// SCP
-		SendMessage(GetDlgItem(hDlgWnd, IDC_SCP_PATH), WM_SETTEXT, 0, (LPARAM)Param->ScpSendDirPtr);
+		SetDlgItemTextA(hDlgWnd, IDC_SCP_PATH, Param->ScpSendDirPtr);
 		if (!Param->ScpEnable) {
 			// \x96\xB3\x8C\xF8\x89\xBB
 			EnableWindow(GetDlgItem(hDlgWnd, IDC_SCP_RADIO), FALSE);
@@ -149,10 +136,10 @@
 
 		// Do this for the next %d files
 		char orgmsg[MAX_UIMSG];
-		GetDlgItemText(hDlgWnd, IDC_SAME_PROCESS_CHECK, orgmsg, sizeof(orgmsg));
+		GetDlgItemTextA(hDlgWnd, IDC_SAME_PROCESS_CHECK, orgmsg, sizeof(orgmsg));
 		char uimsg[MAX_UIMSG];
 		_snprintf_s(uimsg, sizeof(uimsg), _TRUNCATE, orgmsg, Param->RemaingFileCount - 1);
-		SetDlgItemText(hDlgWnd, IDC_SAME_PROCESS_CHECK, uimsg);
+		SetDlgItemTextA(hDlgWnd, IDC_SAME_PROCESS_CHECK, uimsg);
 		if (Param->RemaingFileCount < 2) {
 			EnableWindow(GetDlgItem(hDlgWnd, IDC_SAME_PROCESS_CHECK), FALSE);
 		}
@@ -167,19 +154,16 @@
 		}
 
 		// focus to "SCP dest textbox" or "Cancel"
-		if (Param->ScpEnable) {
-			// "SCP" \x97L\x8C\xF8\x8E\x9E\x82\xCD Cancel \x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂āA\x8DŏI\x93I\x82\xC9 SCP PATH \x82Ƀt\x83H\x81[\x83J\x83X\x82\xAA
-			// \x93\x96\x82\xBD\x82\xE9\x82悤\x82ɂ\xB7\x82\xE9\x81B
-			SetFocus(GetDlgItem(hDlgWnd, IDC_SCP_RADIO));
-		} else {
-			// \x83t\x83H\x81[\x83J\x83X\x82̏\x89\x8A\xFA\x8F\xF3\x91Ԃ\xF0 Cancel \x82ɂ\xB7\x82\xE9\x88ׁA\x82\xB1\x82̎\x9E\x93_\x82ł\xCD IDOK \x82\xC9
-			// \x83t\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9\x81B\x8C\xE3\x82\xC5 WM_NEXTDLGCTL \x82Ńt\x83H\x81[\x83J\x83X\x82\xAA\x8E\x9F\x82̃{\x83^\x83\x93\x82ɂȂ\xE9\x81B
-			SetFocus(GetDlgItem(hDlgWnd, IDOK));
+		{
+			int focus_id;
+			if (Param->ScpEnable) {
+				focus_id = IDC_SCP_PATH;
+			} else {
+				focus_id = IDCANCEL;
+			}
+			PostMessage(hDlgWnd, WM_NEXTDLGCTL,
+						(WPARAM)GetDlgItem(hDlgWnd, focus_id), TRUE);
 		}
-		// \x83t\x83H\x81[\x83J\x83X\x82\xF0\x8E\x9F\x82̃{\x83^\x83\x93\x82Ɉڂ\xB7
-		// SetFocus() \x82Œ\xBC\x90ڃt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9\x82ƃ^\x83u\x83L\x81[\x82̓\xAE\x8D쓙\x82ɖ\xE2\x91肪\x8Fo\x82邽\x82߁A
-		// \x82\xB1\x82̃\x81\x83b\x83Z\x81[\x83W\x82𕹗p\x82\xB7\x82\xE9
-		PostMessage(hDlgWnd, WM_NEXTDLGCTL, 0, 0L);
 
 		// TRUE\x82ɂ\xB7\x82\xE9\x82ƃ{\x83^\x83\x93\x82Ƀt\x83H\x81[\x83J\x83X\x82\xAA\x93\x96\x82\xBD\x82\xE7\x82Ȃ\xA2\x81B
 		return FALSE;
@@ -209,9 +193,8 @@
 			if (IsDlgButtonChecked(hDlgWnd, IDC_SCP_RADIO) == BST_CHECKED) {
 				// SCP
 				DlgData->Param->DropType = DROP_TYPE_SCP;
-				SendMessage(GetDlgItem(hDlgWnd, IDC_SCP_PATH), WM_GETTEXT,
-							(WPARAM)DlgData->Param->ScpSendDirSize,
-							(LPARAM)DlgData->Param->ScpSendDirPtr);
+				GetDlgItemTextA(hDlgWnd, IDC_SCP_PATH,
+								DlgData->Param->ScpSendDirPtr, DlgData->Param->ScpSendDirSize);
 			} else if (IsDlgButtonChecked(hDlgWnd, IDC_SENDFILE_RADIO) == BST_CHECKED) {
 				// Send File
 				DlgData->Param->DropType =
@@ -242,16 +225,12 @@
 			DlgData->Param->DropType = DROP_TYPE_CANCEL;
 		}
 		if (wID == IDOK || wID == IDCANCEL) {
-			EndDialog(hDlgWnd, wID);
+			TTEndDialog(hDlgWnd, wID);
 			break;
 		}
 		return FALSE;
 	}
 	case WM_NCDESTROY:
-		if (DlgData->hNewFont != NULL) {
-			DeleteObject(DlgData->hNewFont);
-			DlgData->hNewFont = NULL;
-		}
 		free(DlgData);
 		break;
 
@@ -263,7 +242,7 @@
 
 enum drop_type ShowDropDialogBox(
 	HINSTANCE hInstance, HWND hWndParent,
-	const char *TargetFilename,
+	const TCHAR *TargetFilename,
 	enum drop_type DefaultDropType,
 	int RemaingFileCount,
 	bool EnableSCP,
@@ -288,7 +267,7 @@
 	Param.ScpSendDirSize = _countof(pts->ScpSendDir);
 	Param.UILanguageFile = pts->UILanguageFile;
 
-	int ret = DialogBoxParam(
+	int ret = TTDialogBoxParam(
 		hInstance, MAKEINTRESOURCE(IDD_DAD_DIALOG),
 		hWndParent, (DLGPROC)OnDragDropDlgProc,
 		(LPARAM)&Param);

Modified: trunk/teraterm/teraterm/dnddlg.h
===================================================================
--- trunk/teraterm/teraterm/dnddlg.h	2019-03-25 14:29:54 UTC (rev 7511)
+++ trunk/teraterm/teraterm/dnddlg.h	2019-03-25 14:45:53 UTC (rev 7512)
@@ -42,7 +42,7 @@
 
 enum drop_type ShowDropDialogBox(
 	HINSTANCE hInstance, HWND hWndParent,
-	const char *TargetFilename,
+	const TCHAR *TargetFilename,
 	enum drop_type DefaultDropType,
 	int RemaingFileCount,
 	bool EnableSCP,


Ttssh2-commit メーリングリストの案内