[Ttssh2-commit] [7775] GetSaveFileName() が適切と思われる箇所で GetOpenFileName() から変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 6月 17日 (月) 00:49:30 JST


Revision: 7775
          https://osdn.net/projects/ttssh2/scm/svn/commits/7775
Author:   maya
Date:     2019-06-17 00:49:30 +0900 (Mon, 17 Jun 2019)
Log Message:
-----------
GetSaveFileName() が適切と思われる箇所で GetOpenFileName() から変更
OPENFILENAME.Flags を変更
  OFN_FORCESHOWHIDDEN が不要と思われる箇所から削除
  OFN_OVERWRITEPROMPT が必要と思われる箇所に追加
  OFN_FILEMUSTEXIST を指定すると OFN_PATHMUSTEXIST が含まれるので削除

- GetOpenFileName() は OFN_FILEMUSTEXIST | OFN_HIDEREADONLY
- GetSaveFileName() は OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT
を基本とする。
- OFN_ALLOWMULTISELECT には OFN_EXPLORER を追加する
- OFN_ENABLETEMPLATE | OFN_ENABLEHOOK には OFN_EXPLORER を追加する

Modified Paths:
--------------
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/ttpfile/ttfile.c
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttmdlg.cpp
    trunk/ttssh2/ttxssh/auth.c
    trunk/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/teraterm/teraterm/addsetting.cpp	2019-06-16 15:49:30 UTC (rev 7775)
@@ -510,7 +510,7 @@
 				get_lang_msg("FILEDLG_SELECT_CONFIRM_STRING_APP_TITLE", uimsg, sizeof(uimsg),
 				             "Choose a file including strings for ConfirmChangePaste", ts.UILanguageFile);
 				ofn.lpstrTitle = uimsg;
-				ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY;
+				ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 				if (GetOpenFileNameA(&ofn) != 0) {
 					SetDlgItemTextA(IDC_CONFIRM_STRING_FILE, ts.ConfirmChangePasteStringFile);
 				}
@@ -1201,7 +1201,7 @@
 				get_lang_msg("FILEDLG_SELECT_LOGVIEW_APP_TITLE", uimsg, sizeof(uimsg),
 				             "Choose a executing file with launching logging file", ts.UILanguageFile);
 				ofn.lpstrTitle = uimsg;
-				ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY;
+				ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 				if (GetOpenFileNameA(&ofn) != 0) {
 					SetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor);
 				}

Modified: trunk/teraterm/ttpfile/ttfile.c
===================================================================
--- trunk/teraterm/ttpfile/ttfile.c	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/teraterm/ttpfile/ttfile.c	2019-06-16 15:49:30 UTC (rev 7775)
@@ -127,9 +127,9 @@
 
 	_chdir(Dir);
 
-	ofn.Flags = OFN_SHOWHELP | OFN_HIDEREADONLY;
 	switch (FuncId) {
 	case GSF_SAVE:
+		ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
 		// \x8F\x89\x8A\xFA\x83t\x83@\x83C\x83\x8B\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xF0\x83v\x83\x8D\x83O\x83\x89\x83\x80\x96{\x91̂\xAA\x82\xA0\x82\xE9\x89ӏ\x8A\x82ɌŒ肷\x82\xE9 (2005.1.6 yutaka)
 		// \x93ǂݍ\x9E\x82܂ꂽteraterm.ini\x82\xAA\x82\xA0\x82\xE9\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82ɌŒ肷\x82\xE9\x81B
 		// \x82\xB1\x82\xEA\x82ɂ\xE6\x82\xE8\x81A/F= \x82Ŏw\x92肳\x82ꂽ\x88ʒu\x82ɕۑ\xB6\x82\xB3\x82\xEA\x82\xE9\x82悤\x82ɂȂ\xE9\x81B(2005.1.26 yutaka)
@@ -145,7 +145,7 @@
 			strncpy_s(ts->SetupFName, sizeof(ts->SetupFName),Name, _TRUNCATE);
 		break;
 	case GSF_RESTORE:
-		ofn.Flags = ofn.Flags | OFN_FILEMUSTEXIST;
+		ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 		get_lang_msg("FILEDLG_RESTORE_SETUP_TITLE", uimsg, sizeof(uimsg), "Tera Term: Restore setup", UILanguageFile);
 		ofn.lpstrTitle = uimsg;
 		Ok = GetOpenFileName(&ofn);
@@ -153,7 +153,7 @@
 			strncpy_s(ts->SetupFName, sizeof(ts->SetupFName),Name, _TRUNCATE);
 		break;
 	case GSF_LOADKEY:
-		ofn.Flags = ofn.Flags | OFN_FILEMUSTEXIST;
+		ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 		get_lang_msg("FILEDLG_LOAD_KEYMAP_TITLE", uimsg, sizeof(uimsg), "Tera Term: Load key map", UILanguageFile);
 		ofn.lpstrTitle = uimsg;
 		Ok = GetOpenFileName(&ofn);
@@ -162,6 +162,8 @@
 		break;
 	}
 
+	ofn.Flags |= OFN_SHOWHELP;
+
 #if defined(_DEBUG)
 	if (!Ok) {
 		DWORD Err = GetLastError();
@@ -516,10 +518,9 @@
 		ofn.lpstrInitialDir = CurDir;
 	}
 
-	ofn.Flags = OFN_SHOWHELP | OFN_HIDEREADONLY;
-
 	switch (FuncId) {
 	case GTF_LOG:
+		ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
 		ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER;
 		ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FOPT);
 
@@ -528,6 +529,7 @@
 		ofn.lCustData = (DWORD)&optl;
 		break;
 	case GTF_SEND:
+		ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 		ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER;
 		ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FOPT);
 
@@ -536,13 +538,13 @@
 		ofn.lCustData = (DWORD)&optw;
 		break;
 	case GTF_BP:
-		// nothing to do
+		ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 		break;
 	}
 
+	ofn.Flags |= OFN_SHOWHELP;
+
 	if (FuncId != GTF_LOG) {
-		ofn.Flags |= OFN_FILEMUSTEXIST;
-
 		// \x83t\x83B\x83\x8B\x83^\x82\xAA\x83\x8F\x83C\x83\x8B\x83h\x83J\x81[\x83h\x82ł͂Ȃ\xAD\x81A\x82\xBB\x82̃t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB7\x82\xE9\x8Fꍇ
 		// \x82\xA0\x82炩\x82\xB6\x82߃f\x83t\x83H\x83\x8B\x83g\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x93\xFC\x82\xEA\x82Ă\xA8\x82\xAD (2008.5.18 maya)
 		if (strlen(FileSendFilter) > 0 &&
@@ -735,10 +737,12 @@
 	ofn.nMaxFile = FnStrMemSize;
 	ofn.lpstrTitle= fv->DlgCaption;
 	ofn.lpstrInitialDir = CurDir;
-	ofn.Flags = OFN_SHOWHELP | OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER;
+	ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+	ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_EXPLORER;
+	ofn.Flags |= OFN_SHOWHELP;
 	ofn.lCustData = 0;
 	if (FuncId==GMF_Z) {
-		ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
+		ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER;
 		ofn.lCustData = (DWORD)Option;
 		ofn.lpfnHook = (LPOFNHOOKPROC)(&TransFnHook);
 		ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FOPT);
@@ -1167,23 +1171,30 @@
 	ofn.lpstrFile = fv->FullName;
 	ofn.nMaxFile = sizeof(fv->FullName);
 	ofn.lpstrInitialDir = CurDir;
-	ofn.Flags = OFN_SHOWHELP | OFN_HIDEREADONLY |
-	            OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
 	opt = *Option;
 	if (! Receive)
 	{
-		ofn.Flags = ofn.Flags | OFN_FILEMUSTEXIST;
+		ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 		opt = opt | 0xFFFF;
 	}
+	else {
+		ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
+	}
+	ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER;
+	ofn.Flags |= OFN_SHOWHELP;
 	ofn.lCustData = (DWORD)&opt;
-
 	ofn.lpstrTitle = fv->DlgCaption;
 	ofn.lpfnHook = (LPOFNHOOKPROC)(&XFnHook);
-	ofn.Flags = ofn.Flags | OFN_EXPLORER;
 	ofn.lpTemplateName = MAKEINTRESOURCE(IDD_XOPT);
 	ofn.hInstance = hInst;
 
-	Ok = GetOpenFileName(&ofn);
+	if (!Receive)
+	{
+		Ok = GetOpenFileName(&ofn);
+	}
+	else {
+		Ok = GetSaveFileName(&ofn);
+	}
 
 	if (Ok) {
 		fv->DirLen = ofn.nFileOffset;

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/teraterm/ttpmacro/ttl.c	2019-06-16 15:49:30 UTC (rev 7775)
@@ -1573,10 +1573,11 @@
 		}
 		BringupWindow(HMainWin);
 		if (SaveFlag) {
-			ofn.Flags = OFN_OVERWRITEPROMPT;
+			ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 			ret = GetSaveFileName(&ofn);
 		}
 		else {
+			ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
 			ret = GetOpenFileName(&ofn);
 		}
 		SetResult(ret);

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-06-16 15:49:30 UTC (rev 7775)
@@ -183,11 +183,12 @@
 
 	// sizeof(OPENFILENAME) \x82ł\xCD Windows98/NT \x82ŏI\x97\xB9\x82\xB5\x82Ă\xB5\x82܂\xA4\x82\xBD\x82\xDF (2006.8.14 maya)
 	FNameRec.lStructSize = get_OPENFILENAME_SIZE();
-	FNameRec.hwndOwner	 = HWin;
-	FNameRec.lpstrFilter	 = FNFilter;
-	FNameRec.nFilterIndex  = 1;
-	FNameRec.lpstrFile  = FileName;
-	FNameRec.nMaxFile  = sizeof(FileName);
+	FNameRec.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+	FNameRec.hwndOwner = HWin;
+	FNameRec.lpstrFilter = FNFilter;
+	FNameRec.nFilterIndex = 1;
+	FNameRec.lpstrFile = FileName;
+	FNameRec.nMaxFile = sizeof(FileName);
 	// \x88ȑO\x93ǂݍ\x9E\x82\xF1\x82\xBE .ttl \x83t\x83@\x83C\x83\x8B\x82̃p\x83X\x82\xF0\x8BL\x89\xAF\x82ł\xAB\x82\xE9\x82悤\x82ɁA\x8F\x89\x8A\xFA\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xF0\x8CŒ\xE8\x82ɂ\xB5\x82Ȃ\xA2\x81B
 	// (2008.4.7 yutaka)
 #if 0

Modified: trunk/ttssh2/ttxssh/auth.c
===================================================================
--- trunk/ttssh2/ttxssh/auth.c	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/ttssh2/ttxssh/auth.c	2019-06-16 15:49:30 UTC (rev 7775)
@@ -494,8 +494,7 @@
 	UTIL_get_lang_msg("FILEDLG_OPEN_PRIVATEKEY_TITLE", pvar,
 	                  "Choose a file with the RSA/DSA/ECDSA/ED25519 private key");
 	params.lpstrTitle = pvar->ts->UIMsg;
-	params.Flags =
-		OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
+	params.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 	params.lpstrDefExt = NULL;
 
 	if (GetOpenFileName(&params) != 0) {

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2019-06-16 03:40:20 UTC (rev 7774)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2019-06-16 15:49:30 UTC (rev 7775)
@@ -3205,8 +3205,7 @@
 		                  "Choose a read/write known-hosts file");
 	}
 	params.lpstrTitle = pvar->ts->UIMsg;
-	params.Flags = (readonly ? OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST : 0)
-	             | OFN_HIDEREADONLY | (!readonly ? OFN_NOREADONLYRETURN : 0);
+	params.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 	params.lpstrDefExt = NULL;
 
 	if (GetOpenFileName(&params) != 0) {
@@ -3856,12 +3855,8 @@
 #endif
 			ofn.lpstrTitle = "Choose a sending file with SCP";
 
-// WINVER \x82\xAA\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xBD\x82߂Ƀ}\x83N\x83\x8D\x82\xAA\x92\xE8\x8B`\x82\xB3\x82\xEA\x82Ȃ\xA2\x82̂ŁA\x82\xB1\x82\xB1\x82Œ\xE8\x8B`\x82\xB7\x82\xE9(2008.1.21 maya)
-#ifndef OFN_FORCESHOWHIDDEN
-/* from commdlg.h */
-#define OFN_FORCESHOWHIDDEN          0x10000000
-#endif
-			ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY;
+			ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+			ofn.Flags |= OFN_FORCESHOWHIDDEN;
 			if (GetOpenFileName(&ofn) != 0) {
 				hWnd = GetDlgItem(dlg, IDC_SENDFILE_EDIT);
 				SendMessage(hWnd, WM_SETTEXT , 0, (LPARAM)sendfile);
@@ -4553,6 +4548,7 @@
 			default:
 				break;
 			}
+			ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
 			ofn.lpstrFile = filename;
 			ofn.nMaxFile = sizeof(filename);
 			UTIL_get_lang_msg("FILEDLG_SAVE_PUBLICKEY_TITLE", pvar,
@@ -4769,6 +4765,7 @@
 			default:
 				break;
 			}
+			ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
 			ofn.lpstrFile = filename;
 			ofn.nMaxFile = sizeof(filename);
 			UTIL_get_lang_msg("FILEDLG_SAVE_PRIVATEKEY_TITLE", pvar,


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