[Ttssh2-commit] [8435] [ファイル]/[ファイル送信]のUI変更

scmno****@osdn***** scmno****@osdn*****
2019年 12月 9日 (月) 23:39:37 JST


Revision: 8435
          https://osdn.net/projects/ttssh2/scm/svn/commits/8435
Author:   zmatsuo
Date:     2019-12-09 23:39:36 +0900 (Mon, 09 Dec 2019)
Log Message:
-----------
[ファイル]/[ファイル送信]のUI変更

- ファイル送信ダイアログを追加
  - 従来はファイル選択ダイアログ(コモンダイアログ)が開いていた
- ダイアログにバイナリオプション
  - 従来はコモンダイアログを拡張してオプションをつけていた
  - このためコモンダイアログが古いスタイルになっていた
  - (注)バイナリ送信は未実装
- ファイルをドロップすることでもファイルを選択できる
- GetCommonDialogFilterW() 追加
  - GetOpenFileName(), GetSaveFileName() 用フィルタ文字列取得

Modified Paths:
--------------
    branches/unicode_buf/teraterm/common/tt_res.h
    branches/unicode_buf/teraterm/teraterm/ttermpro.rc
    branches/unicode_buf/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/common/tt_res.h
===================================================================
--- branches/unicode_buf/teraterm/common/tt_res.h	2019-12-09 14:39:25 UTC (rev 8434)
+++ branches/unicode_buf/teraterm/common/tt_res.h	2019-12-09 14:39:36 UTC (rev 8435)
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ \x82Ő\xB6\x90\xAC\x82\xB3\x82ꂽ\x83C\x83\x93\x83N\x83\x8B\x81[\x83h \x83t\x83@\x83C\x83\x8B\x81B
-// C:\work\teraterm\git\teraterm\teraterm\teraterm\debugpropartypage.rc \x82Ŏg\x97p
+// Microsoft Visual C++ generated include file.
+// Used by ttermpro.rc
 //
 #define IDI_TTERM                       100
 #define IDR_ACC                         100
@@ -26,6 +26,7 @@
 #define IDI_TTERM_3D                    124
 #define IDI_VT_3D                       125
 #define IDD_TABSHEET_DEBUG              126
+#define IDD_SENDFILEDLG                 127
 #define IDR_TEKMENU                     1000
 #define IDC_EDIT_COMMENT                1000
 #define IDC_EDIT_FULLPATH               1001
@@ -245,6 +246,10 @@
 #define IDC_DEBUG_POPUP_KEY1            2592
 #define IDC_DEBUG_POPUP_KEY2            2593
 #define IDC_DEBUG_CONSOLE_BUTTON        2594
+#define IDC_SENDFILE_FILENAME_BUTTON    2595
+#define IDC_SENDFILE_CHECK_BINARY       2596
+#define IDC_SENDFILE_FILENAME_TITLE     2597
+#define IDC_SENDFILE_FILENAME_EDIT      2598
 #define ID_ACC_SENDBREAK                50001
 #define ID_ACC_COPY                     50002
 #define ID_ACC_NEWCONNECTION            50003
@@ -341,9 +346,9 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NO_MFC                     1
-#define _APS_NEXT_RESOURCE_VALUE        127
+#define _APS_NEXT_RESOURCE_VALUE        128
 #define _APS_NEXT_COMMAND_VALUE         52031
-#define _APS_NEXT_CONTROL_VALUE         2594
+#define _APS_NEXT_CONTROL_VALUE         2599
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: branches/unicode_buf/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ttermpro.rc	2019-12-09 14:39:25 UTC (rev 8434)
+++ branches/unicode_buf/teraterm/teraterm/ttermpro.rc	2019-12-09 14:39:36 UTC (rev 8435)
@@ -353,7 +353,21 @@
     EDITTEXT        IDC_SSH_SETUPDIR_EDIT_VSTORE,68,179,251,14,ES_AUTOHSCROLL | ES_READONLY
 END
 
+IDD_SENDFILEDLG DIALOGEX 0, 0, 271, 83
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Send file"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    LTEXT           "&Filename (drop file in this dialog)",IDC_SENDFILE_FILENAME_TITLE,7,7,172,8
+    EDITTEXT        IDC_SENDFILE_FILENAME_EDIT,17,21,224,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "...",IDC_SENDFILE_FILENAME_BUTTON,245,21,14,14
+    CONTROL         "&Binary",IDC_SENDFILE_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,44,72,10
+    PUSHBUTTON      "Help",IDHELP,103,62,50,14
+    DEFPUSHBUTTON   "OK",IDOK,159,62,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,214,62,50,14
+END
 
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // DESIGNINFO
@@ -438,6 +452,10 @@
         BOTTOMMARGIN, 80
     END
 
+    IDD_PROTDLG, DIALOG
+    BEGIN
+    END
+
     IDD_CLIPBOARD_DIALOG, DIALOG
     BEGIN
         LEFTMARGIN, 5

Modified: branches/unicode_buf/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-12-09 14:39:25 UTC (rev 8434)
+++ branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-12-09 14:39:36 UTC (rev 8435)
@@ -75,6 +75,7 @@
 #include <imm.h>
 #include <dbt.h>
 #include <assert.h>
+#include <wchar.h>
 
 #include "tt_res.h"
 #include "vtwin.h"
@@ -1874,6 +1875,16 @@
 	}
 }
 
+static void sendfile(const wchar_t *filename, BOOL binary)
+{
+	char *FileNameA = ToCharW(filename);
+	strncpy_s(SendVar->FullName, sizeof(SendVar->FullName), FileNameA,  _TRUNCATE);
+	free(FileNameA);
+	SendVar->DirLen = 0;
+	ts.TransBin = binary == FALSE ? 0 : 1;
+	FileSendStart();
+}
+
 LRESULT CVTWindow::OnDropNotify(WPARAM ShowDialog, LPARAM lParam)
 {
 	// ini\x82ɕۑ\xB6\x82\xB3\x82\xEA\x82Ȃ\xA2\x81A\x8D\xA1\x8E\xC0\x8Ds\x82\xB5\x82Ă\xA2\x82\xE9Tera Term\x82ł̂ݗL\x8C\xF8\x82Ȑݒ\xE8
@@ -2002,29 +2013,7 @@
 		case DROP_TYPE_SEND_FILE:
 		case DROP_TYPE_SEND_FILE_BINARY:
 			if (SendVar==NULL && NewFileVar(&SendVar)) {
-				HelpId = HlpFileSend;
-				char *FileNameA = ToCharW(FileName);
-				strncpy_s(SendVar->FullName, sizeof(SendVar->FullName), FileNameA,  _TRUNCATE);
-				free(FileNameA);
-				SendVar->DirLen = 0;
-				ts.TransBin = DropType == DROP_TYPE_SEND_FILE ? 0 : 1;
-				FileSendStart();
-#if 0
-#if 0
-				goto finish;	// send file\x82͘A\x91\xB1\x82\xB5\x82Ăł\xAB\x82Ȃ\xA2
-#else
-				{
-					LONG lCount = 0;
-					CWinApp *app = AfxGetApp();
-					while(1) {
-						if (SendVar == NULL) {
-							break;
-						}
-						app->OnIdle(lCount++);
-					}
-				}
-#endif
-#endif
+				sendfile(FileName, DropType == DROP_TYPE_SEND_FILE ? 0 : 1);
 			}
 			break;
 		case DROP_TYPE_PASTE_FILENAME:
@@ -2073,12 +2062,13 @@
 		DropLists = (wchar_t **)malloc(sizeof(wchar_t *) * DropListCount);
 
 		for (int i = 0; i < DropListCount; i++) {
-			const UINT cch = _DragQueryFileW(hDropInfo, i, NULL, 0) + 1;
+			const UINT cch = _DragQueryFileW(hDropInfo, i, NULL, 0);
 			if (cch == 0) {
 				continue;
 			}
-			wchar_t *FileName = (wchar_t *)malloc(sizeof(wchar_t) * cch);
-			_DragQueryFileW(hDropInfo,i,FileName,cch);
+			wchar_t *FileName = (wchar_t *)malloc(sizeof(wchar_t) * (cch + 1));
+			_DragQueryFileW(hDropInfo,i,FileName,cch + 1);
+			FileName[cch] = '\0';
 			DropLists[i] = FileName;
 		}
 
@@ -4228,59 +4218,290 @@
 	}
 }
 
+/**
+ *	GetOpenFileName(), GetSaveFileName() \x97p\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x8E擾
+ *
+ *	@param[in]	user_filter_mask	\x83\x86\x81[\x83U\x81[\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1
+ *									"*.txt", "*.txt;*.log" \x82Ȃ\xC7
+ *									NULL\x82̂Ƃ\xAB\x8Eg\x97p\x82\xB5\x82Ȃ\xA2
+ *	@param[in]	UILanguageFile
+ *	@param[out]	len					\x90\xB6\x90\xAC\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x92\xB7(wchar_t\x92P\x88\xCA)
+ *									NULL\x82̂Ƃ\xAB\x82͕Ԃ\xB3\x82Ȃ\xA2
+ *	@retval		"User define(*.txt)\0*.txt\0All(*.*)\0*.*\0" \x82Ȃ\xC7
+ *				\x8FI\x92[\x82\xCD "\0\0" \x82ƂȂ\xE9
+ */
+static wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile, size_t *len)
+{
+	// "\x83\x86\x81[\x83U\x92\xE8\x8B`(*.txt)\0*.txt"
+	wchar_t *user_filter_str = L"";
+	size_t user_filter_len = 0;
+	if (user_filter_mask != NULL && user_filter_mask[0] != 0) {
+		wchar_t user_filter_name[MAX_UIMSG];
+		get_lang_msgW("FILEDLG_USER_FILTER_NAME", user_filter_name, sizeof(user_filter_name), L"User define",
+					 UILanguageFile);
+		size_t user_filter_name_len = wcslen(user_filter_name);
+		wchar_t *user_filter_maskW = ToWcharA(user_filter_mask);
+		size_t user_filter_mask_len = wcslen(user_filter_maskW);
+		user_filter_len = user_filter_name_len + 1 + user_filter_mask_len + 1 + 1 + user_filter_mask_len + 1;
+		user_filter_str = (wchar_t *)malloc(user_filter_len * sizeof(wchar_t));
+		wchar_t *p = user_filter_str;
+		wmemcpy(p, user_filter_name, user_filter_name_len);
+		p += user_filter_name_len;
+		*p++ = '(';
+		wmemcpy(p, user_filter_maskW, user_filter_mask_len);
+		p += user_filter_mask_len;
+		*p++ = ')';
+		*p++ = '\0';
+		wmemcpy(p, user_filter_maskW, user_filter_mask_len);
+		p += user_filter_mask_len;
+		*p++ = '\0';
+		free(user_filter_maskW);
+	}
 
-void CVTWindow::OnFileSend()
-{
-	HelpId = HlpFileSend;
-#if !UNICODE_INTERNAL_BUFF
-	FileSendStart();
-#else
+	// "\x82\xB7\x82ׂẴt\x83@\x83C\x83\x8B(*.*)\0*.*"
+	wchar_t all_filter_str[MAX_UIMSG];
+	get_lang_msgW("FILEDLG_ALL_FILTER", all_filter_str, _countof(all_filter_str), L"All(*.*)\\0*.*", UILanguageFile);
+	size_t all_filter_len;
 	{
-		char TempDir[MAXPATHLEN];
-		GetCurrentDirectory(sizeof(TempDir), TempDir);
+		size_t all_filter_title_len = wcsnlen(all_filter_str, _countof(all_filter_str));
+		if (all_filter_title_len == 0 || all_filter_title_len == _countof(all_filter_str)) {
+			all_filter_str[0] = 0;
+			all_filter_len = 0;
+		} else {
+			size_t all_filter_mask_max = _countof(all_filter_str) - all_filter_title_len - 1;
+			size_t all_filter_mask_len = wcsnlen(all_filter_str + all_filter_title_len + 1, all_filter_mask_max);
+			if (all_filter_mask_len == 0 || all_filter_mask_len == _countof(all_filter_str)) {
+				all_filter_str[0] = 0;
+				all_filter_len = 0;
+			} else {
+				all_filter_len = all_filter_title_len + 1 + all_filter_mask_len + 1;
+			}
+		}
+	}
 
-		char file_name[MAX_PATH];
-		file_name[0] = 0;
-		OPENFILENAME ofn;
-		memset(&ofn, 0, sizeof(OPENFILENAME));
-		ofn.lStructSize = get_OPENFILENAME_SIZE();
-		ofn.hwndOwner   = m_hWnd;
-		ofn.lpstrFile = file_name;
-		ofn.nMaxFile = sizeof(file_name);
-		ofn.nMaxFile = MAX_PATH;
-		ofn.lpstrFilter = 	TEXT("Text files {*.txt}\0*.txt\0")
-			TEXT("HTML files {*.htm}\0*.htm;*.html\0")
-			TEXT("All files {*.*}\0*.*\0\0");
-		ofn.nFilterIndex = 0;
-		ofn.lpstrTitle = "test";
-		ofn.Flags = OFN_FILEMUSTEXIST;
-		BOOL Ok = GetOpenFileName(&ofn);
-		DWORD err = GetLastError();
+	// \x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8D\xEC\x82\xE9
+	size_t filter_len = user_filter_len + all_filter_len;
+	wchar_t* filter_str;
+	if (filter_len != 0) {
+		filter_len++;
+		filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t));
+		wchar_t *p = filter_str;
+		if (user_filter_len != 0) {
+			wmemcpy(p, user_filter_str, user_filter_len);
+			p += user_filter_len;
+		}
+		wmemcpy(p, all_filter_str, all_filter_len);
+		p += all_filter_len;
+		*p = '\0';
+	} else {
+		filter_len = 2;
+		filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t));
+		filter_str[0] = 0;
+		filter_str[1] = 0;
+	}
 
-		SetCurrentDirectory(TempDir);
+	if (user_filter_len != 0) {
+		free(user_filter_str);
+	}
 
-		if (Ok == FALSE) {
-			return;
-		}
+	if (len != NULL) {
+		*len = filter_len;
+	}
+	return filter_str;
+}
 
-		size_t str_len;
-		wchar_t *str_ptr = LoadFileWA(file_name, &str_len);
-		if (str_ptr == NULL) {
-			return;
-		}
-		str_len *= sizeof(wchar_t);
+typedef struct {
+	// in
+	const char* UILanguageFile;
+	// out
+	wchar_t* filename;		// IDOK\x8E\x9E\x81A\x91I\x91\xF0\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xAA\x95Ԃ\xE9,\x8Eg\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6
+	BOOL binary;			// TRUE/FALSE = \x83o\x83C\x83i\x83\x8A/\x83e\x83L\x83X\x83g
+	// work
+	WORD MsgDlgHelp;
+} sendfiledlgdata;
 
-		{
-			SendMem *sm = SendMemInit(str_ptr, str_len, SendMemTypeTextLF);
-			//SendMemInitDelay(sm, 10, 0);
-			SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
-			SendMemInitDialogCaption(sm, L"send file");
-			wchar_t *file_name_w = ToWcharA(file_name);
-			SendMemInitDialogFilename(sm, file_name_w);
-			free(file_name_w);
-			SendMemStart(sm);
+static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	static const DlgTextInfo TextInfos[] = {
+		{0, "FILEDLG_TRANS_TITLE_SENDFILE"},
+		{IDC_SENDFILE_FILENAME_TITLE, "DLG_SENDFILE_FILENAME_TITLE"},
+		{IDC_SENDFILE_CHECK_BINARY, "DLG_FOPT_BINARY"},
+		{IDCANCEL, "BTN_CANCEL"},
+		{IDOK, "BTN_OK"},
+	};
+	sendfiledlgdata *data = (sendfiledlgdata *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+
+	if (data != NULL && msg == data->MsgDlgHelp) {
+		PostMessage(GetParent(hDlgWnd), WM_USER_DLGHELP2, HlpMenuFileSendfile, 0);
+		return TRUE;
+	}
+	switch (msg) {
+		case WM_INITDIALOG:
+			data = (sendfiledlgdata *)lp;
+			SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
+			::DragAcceptFiles(hDlgWnd, TRUE);
+			SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), data->UILanguageFile);
+			CenterWindow(hDlgWnd, GetParent(hDlgWnd));
+			EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_CHECK_BINARY), FALSE);
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (wp) {
+				case IDOK | (BN_CLICKED << 16): {
+					size_t len = _SendDlgItemMessageW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, WM_GETTEXTLENGTH, 0, 0);
+					len++;  // for '\0'
+					wchar_t *strW = (wchar_t *)malloc(sizeof(wchar_t) * len);
+					if (strW != NULL) {
+						_GetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, strW, (int)len);
+						strW[len - 1] = '\0';
+					}
+
+					const DWORD attr = _GetFileAttributesW(strW);
+					if (attr == INVALID_FILE_ATTRIBUTES || attr & FILE_ATTRIBUTE_DIRECTORY) {
+						wchar_t caption[MAX_UIMSG];
+						wchar_t message[MAX_UIMSG];
+
+						get_lang_msgW("MSG_TT_ERROR", caption, _countof(caption), L"Tera Term: Error",
+									  data->UILanguageFile);
+						get_lang_msgW("MSG_CANTOPEN_FILE_ERROR", message, _countof(message), L"Cannot open file",
+									  data->UILanguageFile);
+						MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION);
+
+						free(strW);
+
+						PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT),
+									TRUE);
+
+						return TRUE;
+					}
+
+					data->filename = strW;
+					data->binary =
+						SendMessage(GetDlgItem(hDlgWnd, IDC_SENDFILE_CHECK_BINARY), BM_GETCHECK, 0, 0) == BST_CHECKED
+							? TRUE
+							: FALSE;
+					TTEndDialog(hDlgWnd, IDOK);
+					return TRUE;
+				}
+
+				case IDHELP | (BN_CLICKED << 16):
+					PostMessage(GetParent(hDlgWnd), WM_USER_DLGHELP2, HlpMenuFileSendfile, 0);
+					return TRUE;
+
+				case IDCANCEL | (BN_CLICKED << 16):
+					data->filename = NULL;
+					TTEndDialog(hDlgWnd, IDCANCEL);
+					return TRUE;
+
+				case IDC_SENDFILE_FILENAME_BUTTON | (BN_CLICKED << 16): {
+					char TempDir[MAX_PATH];
+					GetCurrentDirectoryA(sizeof(TempDir), TempDir);
+
+					char title[40];
+					char uimsg[MAX_UIMSG];
+					get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile,
+								 data->UILanguageFile);
+					strcpy(title, "Tera Term: ");
+					strncat_s(title, _countof(title), uimsg, _TRUNCATE);
+
+					size_t filter_len;
+					wchar_t *filterW = GetCommonDialogFilterW(ts.FileSendFilter, data->UILanguageFile, &filter_len);
+					char *filterA = _WideCharToMultiByte(filterW, filter_len, CP_ACP, NULL);
+					free(filterW);
+
+					char filename[MAX_PATH];
+					filename[0] = 0;
+					OPENFILENAME ofn = {};
+					ofn.lStructSize = get_OPENFILENAME_SIZE();
+					ofn.hwndOwner = hDlgWnd;
+					ofn.lpstrFile = filename;
+					ofn.nMaxFile = sizeof(filename);
+					ofn.nMaxFile = MAX_PATH;
+					ofn.lpstrFilter = filterA;
+					ofn.nFilterIndex = 0;
+					ofn.lpstrTitle = title;
+					ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY;
+					BOOL Ok = GetOpenFileNameA(&ofn);
+					free(filterA);
+
+					SetCurrentDirectoryA(TempDir);
+
+					if (Ok) {
+						SetDlgItemTextA(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, filename);
+						size_t len = strlen(filename);
+						SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, EM_SETSEL, len, len);
+						PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDOK), TRUE);
+					}
+
+					return TRUE;
+				}
+				default:
+					return FALSE;
+			}
+			return FALSE;
+
+		case WM_DROPFILES: {
+			// \x95\xA1\x90\x94\x83h\x83\x8D\x83b\x83v\x82\xB3\x82\xEA\x82Ă\xE0\x8Dŏ\x89\x82\xCC1\x82‚\xBE\x82\xAF\x82\xF0\x88\xB5\x82\xA4
+			HDROP hDrop = (HDROP)wp;
+			const UINT len = _DragQueryFileW(hDrop, 0, NULL, 0);
+			if (len == 0) {
+				DragFinish(hDrop);
+				return TRUE;
+			}
+			wchar_t *filename = (wchar_t *)malloc(sizeof(wchar_t) * (len + 1));
+			_DragQueryFileW(hDrop, 0, filename, len + 1);
+			filename[len] = '\0';
+			_SetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, filename);
+			SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, EM_SETSEL, len, len);
+			PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDOK), TRUE);
+
+			free(filename);
+			DragFinish(hDrop);
+			return TRUE;
 		}
+		default:
+			return FALSE;
 	}
+}
+
+static INT_PTR sendfiledlg(HINSTANCE hInstance, HWND hWndParent, sendfiledlgdata *data)
+{
+	INT_PTR ret;
+	ret = TTDialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SENDFILEDLG), hWndParent, SendFileDlgProc, (LPARAM)data);
+	return ret;
+}
+
+void CVTWindow::OnFileSend()
+{
+#if !UNICODE_INTERNAL_BUFF
+	HelpId = HlpFileSend;
+	FileSendStart();
+#else
+	SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
+				  ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT");
+	sendfiledlgdata data;
+	data.UILanguageFile = ts.UILanguageFile;
+	data.MsgDlgHelp = RegisterWindowMessage(HELPMSGSTRING);
+	INT_PTR ok = sendfiledlg(m_hInst, m_hWnd, &data);
+	if (ok != IDOK) {
+		return;
+	}
+
+	wchar_t *filename = data.filename;
+	size_t str_len;
+	wchar_t *str_ptr = LoadFileWW(filename, &str_len);
+	if (str_ptr == NULL) {
+		goto finish;
+	}
+	str_len *= sizeof(wchar_t);
+
+	SendMem *sm = SendMemInit(str_ptr, str_len, SendMemTypeTextLF);
+	SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
+	SendMemInitDialogCaption(sm, L"send file");			// title
+	SendMemInitDialogFilename(sm, filename);
+	SendMemStart(sm);
+finish:
+	free(filename);
 #endif
 }
 
@@ -6643,3 +6864,5 @@
 	}
 	return retval;
 }
+
+


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