[Ttssh2-commit] [5778] doSelectFolder() がフォルダ選択の成功と失敗を返すようにした

svnno****@sourc***** svnno****@sourc*****
2015年 2月 13日 (金) 17:34:54 JST


Revision: 5778
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5778
Author:   maya
Date:     2015-02-13 17:34:51 +0900 (Fri, 13 Feb 2015)
Log Message:
-----------
doSelectFolder() がフォルダ選択の成功と失敗を返すようにした

Modified Paths:
--------------
    trunk/teraterm/common/ttlib.c
    trunk/teraterm/common/ttlib.h
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: trunk/teraterm/common/ttlib.c
===================================================================
--- trunk/teraterm/common/ttlib.c	2015-02-05 13:55:24 UTC (rev 5777)
+++ trunk/teraterm/common/ttlib.c	2015-02-13 08:34:51 UTC (rev 5778)
@@ -903,12 +903,13 @@
 	return 0;
 }
 
-void doSelectFolder(HWND hWnd, char *path, int pathlen, char *msg)
+BOOL doSelectFolder(HWND hWnd, char *path, int pathlen, char *def, char *msg)
 {
 	BROWSEINFO      bi;
 	LPITEMIDLIST    pidlRoot;      // \x83u\x83\x89\x83E\x83Y\x82̃\x8B\x81[\x83gPIDL
 	LPITEMIDLIST    pidlBrowse;    // \x83\x86\x81[\x83U\x81[\x82\xAA\x91I\x91\xF0\x82\xB5\x82\xBDPIDL
 	char buf[MAX_PATH];
+	BOOL ret = FALSE;
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x95\\x8E\xA6\x8E\x9E\x82̃\x8B\x81[\x83g\x83t\x83H\x83\x8B\x83_\x82\xCCPIDL\x82\xF0\x8E擾
 	// \x81\xA6\x88ȉ\xBA\x82̓f\x83X\x83N\x83g\x83b\x83v\x82\xF0\x83\x8B\x81[\x83g\x82Ƃ\xB5\x82Ă\xA2\x82\xE9\x81B\x83f\x83X\x83N\x83g\x83b\x83v\x82\xF0\x83\x8B\x81[\x83g\x82Ƃ\xB7\x82\xE9
@@ -916,7 +917,7 @@
 	//   \x8E\xEA\x83t\x83H\x83\x8B\x83_\x82\xF0\x83\x8B\x81[\x83g\x82Ƃ\xB7\x82鎖\x82\xE0\x82ł\xAB\x82\xE9\x81B\x8Fڍׂ\xCDSHGetSpecialFolderLoca
 	//   tion\x82̃w\x83\x8B\x83v\x82\xF0\x8EQ\x8FƂ̎\x96\x81B
 	if (!SUCCEEDED(SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, &pidlRoot))) {
-			return;
+		return FALSE;
 	}
 
 	// BROWSEINFO\x8D\\x91\xA2\x91̂̏\x89\x8A\xFA\x92l\x90ݒ\xE8
@@ -927,7 +928,7 @@
 	bi.lpszTitle = msg;
 	bi.ulFlags = 0;
 	bi.lpfn = setDefaultFolder;
-	bi.lParam = (LPARAM)path;
+	bi.lParam = (LPARAM)def;
 	// \x83t\x83H\x83\x8B\x83_\x91I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O\x82̕\\x8E\xA6 
 	pidlBrowse = SHBrowseForFolder(&bi);
 	if (pidlBrowse != NULL) {  
@@ -935,12 +936,15 @@
 		if (SHGetPathFromIDList(pidlBrowse, buf)) {
 			// \x8E擾\x90\xAC\x8C\xF7
 			strncpy_s(path, pathlen, buf, _TRUNCATE);
+			ret = TRUE;
 		}
 		// SHBrowseForFolder\x82̖߂\xE8\x92lPIDL\x82\xF0\x89\xF0\x95\xFA
 		CoTaskMemFree(pidlBrowse);
 	}
 	// \x83N\x83\x8A\x81[\x83\x93\x83A\x83b\x83v\x8F\x88\x97\x9D
 	CoTaskMemFree(pidlRoot);
+
+	return ret;
 }
 
 void OutputDebugPrintf(char *fmt, ...) {

Modified: trunk/teraterm/common/ttlib.h
===================================================================
--- trunk/teraterm/common/ttlib.h	2015-02-05 13:55:24 UTC (rev 5777)
+++ trunk/teraterm/common/ttlib.h	2015-02-13 08:34:51 UTC (rev 5778)
@@ -42,7 +42,7 @@
 void GetOnOffEntryInifile(char *entry, char *buf, int buflen);
 void get_lang_msg(PCHAR key, PCHAR buf, int buf_len, PCHAR def, PCHAR iniFile);
 int get_lang_font(PCHAR key, HWND dlg, PLOGFONT logfont, HFONT *font, PCHAR iniFile);
-void doSelectFolder(HWND hWnd, char *path, int pathlen, char *msg);
+BOOL doSelectFolder(HWND hWnd, char *path, int pathlen, char *def, char *msg);
 void OutputDebugPrintf(char *fmt, ...);
 BOOL is_NT4();
 int get_OPENFILENAME_SIZE();

Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2015-02-05 13:55:24 UTC (rev 5777)
+++ trunk/teraterm/teraterm/addsetting.cpp	2015-02-13 08:34:51 UTC (rev 5778)
@@ -1418,6 +1418,7 @@
 BOOL CLogPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
 	char uimsg[MAX_UIMSG];
+	char buf[MAX_PATH], buf2[MAX_PATH];
 
 	switch (wParam) {
 		case IDC_VIEWLOG_PATH | (BN_CLICKED << 16):
@@ -1446,9 +1447,10 @@
 			// \x83\x8D\x83O\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82̑I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O
 			get_lang_msg("FILEDLG_SELECT_LOGDIR_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
 			             "Select log folder", ts.UILanguageFile);
-			doSelectFolder(GetSafeHwnd(), ts.LogDefaultPath, sizeof(ts.LogDefaultPath),
-			               ts.UIMsg);
-			SetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath);
+			GetDlgItemText(IDC_DEFAULTPATH_EDITOR, buf, sizeof(buf));
+			if (doSelectFolder(GetSafeHwnd(), buf2, sizeof(buf2), buf, ts.UIMsg)) {
+				SetDlgItemText(IDC_DEFAULTPATH_EDITOR, buf2);
+			}
 
 			return TRUE;
 
@@ -1800,15 +1802,17 @@
 
 BOOL CCygwinPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
+	char buf[MAX_PATH], buf2[MAX_PATH];
+
 	switch (wParam) {
 		case IDC_SELECT_FILE | (BN_CLICKED << 16):
 			// Cygwin install \x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82̑I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O
 			get_lang_msg("DIRDLG_CYGTERM_DIR_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
 			             "Select Cygwin directory", ts.UILanguageFile);
-			doSelectFolder(GetSafeHwnd(), ts.CygwinDirectory, sizeof(ts.CygwinDirectory),
-			               ts.UIMsg);
-			// Cygwin install path
-			SetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory);
+			GetDlgItemText(IDC_CYGWIN_PATH, buf, sizeof(buf));
+			if (doSelectFolder(GetSafeHwnd(), buf2, sizeof(buf2), buf, ts.UIMsg)) {
+				SetDlgItemText(IDC_CYGWIN_PATH, buf2);
+			}
 			return TRUE;
 	}
 

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2015-02-05 13:55:24 UTC (rev 5777)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2015-02-13 08:34:51 UTC (rev 5778)
@@ -2232,6 +2232,7 @@
 	POINT D, B, S;
 	int WX, WY, WW, WH, CW, DW, DH, BW, BH, SW, SH;
 	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
+	char buf[MAX_PATH], buf2[MAX_PATH];
 	LOGFONT logfont;
 	HFONT font;
 
@@ -2384,9 +2385,10 @@
 				case IDC_SELECT_DIR:
 					get_lang_msg("DLG_SELECT_DIR_TITLE", uimsg, sizeof(uimsg),
 					             "Select new directory", UILanguageFile);
-					GetDlgItemText(Dialog, IDC_DIRCURRENT, uimsg2, sizeof(uimsg2));
-					doSelectFolder(Dialog, uimsg2, sizeof(uimsg2), uimsg);
-					SetDlgItemText(Dialog, IDC_DIRNEW, uimsg2);
+					GetDlgItemText(Dialog, IDC_DIRNEW, buf, sizeof(buf));
+					if (doSelectFolder(Dialog, buf2, sizeof(buf2), buf, uimsg)) {
+						SetDlgItemText(Dialog, IDC_DIRNEW, buf2);
+					}
 					return TRUE;
 
 				case IDC_DIRHELP:

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2015-02-05 13:55:24 UTC (rev 5777)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2015-02-13 08:34:51 UTC (rev 5778)
@@ -3987,13 +3987,13 @@
 
 		// SCP\x83t\x83@\x83C\x83\x8B\x91\x97\x90M\x90\xE6\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9
 		if (sendfiledir[0] == '\0') {
-			_snprintf_s(sendfiledir, MAX_PATH, _TRUNCATE, pvar->ts->ScpSendDir); // home directory
+			_snprintf_s(sendfiledir, sizeof(sendfiledir), _TRUNCATE, pvar->ts->ScpSendDir); // home directory
 		}
 		SendMessage(GetDlgItem(dlg, IDC_SENDFILE_TO), WM_SETTEXT, 0, (LPARAM)sendfiledir);
 
 		// SCP\x83t\x83@\x83C\x83\x8B\x8E\xF3\x90M\x90\xE6\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9
 		if (recvdir[0] == '\0') {
-			_snprintf_s(recvdir, MAX_PATH, _TRUNCATE, "%s", pvar->ts->FileDir);
+			_snprintf_s(recvdir, sizeof(recvdir), _TRUNCATE, "%s", pvar->ts->FileDir);
 		}
 		SendMessage(GetDlgItem(dlg, IDC_RECVFILE_TO), WM_SETTEXT, 0, (LPARAM)recvdir);
 
@@ -4054,9 +4054,14 @@
 			return TRUE;
 		case IDC_RECVDIR_SELECT | (BN_CLICKED << 16):
 			{
-			doSelectFolder(dlg, recvdir, MAX_PATH, "Choose destination directory");
-			SendMessage(GetDlgItem(dlg, IDC_RECVFILE_TO), WM_SETTEXT, 0, (LPARAM)recvdir);
+			char buf[MAX_PATH], buf2[MAX_PATH];
+			hWnd = GetDlgItem(dlg, IDC_RECVFILE_TO);
+			SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
+			if (doSelectFolder(dlg, buf2, sizeof(buf2), buf, "Choose destination directory")) {
+				strncpy_s(recvdir, sizeof(recvdir), buf2, _TRUNCATE);
+				SendMessage(GetDlgItem(dlg, IDC_RECVFILE_TO), WM_SETTEXT, 0, (LPARAM)recvdir);
 			}
+			}
 			return TRUE;
 		}
 
@@ -4067,7 +4072,7 @@
 			if (sendfile[0] != '\0') {
 				// \x91\x97\x90M\x83p\x83X\x82\xF0\x8E\xE6\x82\xE8\x8Fo\x82\xB5\x81Ateraterm.ini \x82\xE0\x8D\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B
 				hWnd = GetDlgItem(dlg, IDC_SENDFILE_TO);
-				SendMessage(hWnd, WM_GETTEXT , sizeof(sendfiledir), (LPARAM)sendfiledir);	
+				SendMessage(hWnd, WM_GETTEXT , sizeof(sendfiledir), (LPARAM)sendfiledir);
 				strncpy_s(pvar->ts->ScpSendDir, sizeof(pvar->ts->ScpSendDir), sendfiledir, _TRUNCATE);
 
 				SSH_start_scp(pvar, sendfile, sendfiledir);
@@ -4080,12 +4085,12 @@
 		case IDCANCEL:
 			// \x91\x97\x90M\x83p\x83X\x82\xF0\x8E\xE6\x82\xE8\x8Fo\x82\xB5\x81Ateraterm.ini \x82\xE0\x8D\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B
 			hWnd = GetDlgItem(dlg, IDC_SENDFILE_TO);
-			SendMessage(hWnd, WM_GETTEXT , sizeof(sendfiledir), (LPARAM)sendfiledir);	
+			SendMessage(hWnd, WM_GETTEXT , sizeof(sendfiledir), (LPARAM)sendfiledir);
 			strncpy_s(pvar->ts->ScpSendDir, sizeof(pvar->ts->ScpSendDir), sendfiledir, _TRUNCATE);
 
 			// \x8E\xF3\x90M\x83p\x83X\x82Ɋւ\xB5\x82Ă\xE0\x8DX\x90V\x82\xB7\x82\xE9\x81B(2013.8.18 yutaka)
 			hWnd = GetDlgItem(dlg, IDC_RECVFILE_TO);
-			SendMessage(hWnd, WM_GETTEXT , sizeof(recvdir), (LPARAM)recvdir);	
+			SendMessage(hWnd, WM_GETTEXT , sizeof(recvdir), (LPARAM)recvdir);
 			strncpy_s(pvar->ts->FileDir, sizeof(pvar->ts->FileDir), recvdir, _TRUNCATE);
 
 			EndDialog(dlg, 0); // dialog close
@@ -4101,7 +4106,7 @@
 					return FALSE;
 				}
 				SendMessage(GetDlgItem(dlg, IDC_RECVFILE_TO), WM_GETTEXT, sizeof(recvdir), (LPARAM)recvdir);
-				_snprintf_s(recvpath, MAX_PATH, _TRUNCATE, "%s\\%s", recvdir, fn ? (fn + 1) : szFileName);
+				_snprintf_s(recvpath, sizeof(recvpath), _TRUNCATE, "%s\\%s", recvdir, fn ? (fn + 1) : szFileName);
 				SSH_scp_transaction(pvar, szFileName, recvpath, FROMREMOTE);
 				EndDialog(dlg, 1); // dialog close
 				return TRUE;



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