[Ttssh2-commit] [8536] ファイル送信時、ディレイ設定を行えるようにした

scmno****@osdn***** scmno****@osdn*****
2020年 2月 12日 (水) 00:56:20 JST


Revision: 8536
          https://osdn.net/projects/ttssh2/scm/svn/commits/8536
Author:   zmatsuo
Date:     2020-02-12 00:56:16 +0900 (Wed, 12 Feb 2020)
Log Message:
-----------
ファイル送信時、ディレイ設定を行えるようにした

- 送信サイズ毎のディレイを設定できるようにした
- 送信ファイルダイアログを別ファイルに分離
  - vtwin.cpp -> sendfiledlg.cpp,h
- [Ttssh2-devel 4345]
- [Ttssh2-devel 1112]を含むスレッド
- ドキュメント追記(jpのみ)
- 保守プロジェクトは vs2005, vs2019, cmake

Modified Paths:
--------------
    branches/sendmem_sendsize/doc/ja/html/menu/file-sendfile.html
    branches/sendmem_sendsize/teraterm/common/tt_res.h
    branches/sendmem_sendsize/teraterm/teraterm/CMakeLists.txt
    branches/sendmem_sendsize/teraterm/teraterm/clipboar.c
    branches/sendmem_sendsize/teraterm/teraterm/sendmem.cpp
    branches/sendmem_sendsize/teraterm/teraterm/sendmem.h
    branches/sendmem_sendsize/teraterm/teraterm/ttermpro.rc
    branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj
    branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj.filters
    branches/sendmem_sendsize/teraterm/teraterm/ttermpro.vcproj
    branches/sendmem_sendsize/teraterm/teraterm/vtwin.cpp

Added Paths:
-----------
    branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.cpp
    branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.h

-------------- next part --------------
Modified: branches/sendmem_sendsize/doc/ja/html/menu/file-sendfile.html
===================================================================
--- branches/sendmem_sendsize/doc/ja/html/menu/file-sendfile.html	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/doc/ja/html/menu/file-sendfile.html	2020-02-11 15:56:16 UTC (rev 8536)
@@ -28,8 +28,93 @@
 	\x91I\x91\xF0\x82\xB5\x82Ȃ\xA2\x8Fꍇ\x82́A\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x81A\x89\xFC\x8Ds\x95\xB6\x8E\x9A\x82\xAA\x95ϊ\xB7\x82\xB3\x82\xEA\x82đ\x97\x90M\x82\xB3\x82\xEA\x81A
 	TAB ($09), LF ($0A), CR ($0D)\x88ȊO\x82̐\xA7\x8C䕶\x8E\x9A\x82͑\x97\x90M\x82\xB3\x82\xEA\x82܂\xB9\x82\xF1\x81B
       </dd>
+
+      <dt>delay type</dt>
+      <dd>
+        dd\x82ł\xB7
+        <dl>
+          <dt>no delay</dt>
+          <dd>
+            \x83f\x83B\x83\x8C\x83C\x8F\x88\x97\x9D\x82Ȃ\xB5
+          </dd>
+
+          <dt>per charactor</dt>
+          <dd>
+            1\x95\xB6\x8E\x9A\x96\x88\x82Ƀf\x83B\x83\x8C\x83C\x8F\x88\x97\x9D\x82\xF0\x8Ds\x82\xA4
+          </dd>
+
+          <dt>per line</dt>
+          <dd>
+            1\x8Ds\x96\x88\x82Ƀf\x83B\x83\x8C\x83C\x8F\x88\x97\x9D\x82\xF0\x8Ds\x82\xA4
+          </dd>
+
+          <dt>per sendsize</dt>
+          <dd>
+            \x8Ew\x92著\x90M\x95\xB6\x8E\x9A\x96\x88\x82Ƀf\x83B\x83\x8C\x83C\x8F\x88\x97\x9D\x82\xF0\x8Ds\x82\xA4
+          </dd>
+        </dl>
+
+      </dd>
+
+      <dt>send size</dt>
+      <dd>
+        \x91\x97\x90M\x83T\x83C\x83Y(delay type\x82\xAA per sendsize\x82̂Ƃ\xAB\x97L\x8C\xF8)
+      </dd>
+
+      <dt>dealy time(ms)</dt>
+      <dd>
+        \x83f\x83B\x83\x8C\x83C\x8E\x9E\x8A\xD4
+      </dd>
     </dl>
 
+    <h3>\x91\x97\x90M\x83T\x83C\x83Y</h3>
+
+    <p>
+      Tera Term\x82̒ʐM\x91\x8A\x8E\xE8\x82̎\xF3\x90M\x83o\x83b\x83t\x83@\x83T\x83C\x83Y\x82Ə\x88\x97\x9D\x91\xAC\x93x\x82\xF0\x8Dl\x97\xB6\x82\xB7\x82邱\x82ƂŁA
+      \x8Ew\x92肵\x82\xBD\x91\x97\x90M\x83T\x83C\x83Y\x96\x88\x82Ƀf\x83B\x83\x8C\x83C\x82\xF0\x93\xFC\x82\xEA\x82邱\x82ƂŁA
+      1\x83L\x83\x83\x83\x89\x83N\x83^\x96\x88\x81A1\x8Ds\x96\x88\x82Ƀf\x83B\x83\x8C\x83C\x82\xF0\x93\xFC\x82\xEA\x82\xE9\x82\xE6\x82\xE8\x8C\xF8\x97\xA6\x93I\x82Ƀt\x83@\x83C\x83\x8B\x91\x97\x90M\x82\xF0\x8Ds\x82\xA4\x82\xB1\x82Ƃ\xAA\x82ł\xAB\x82܂\xB7\x81B
+    </p>
+
+    <p>
+      \x91\x97\x90M\x83f\x81[\x83^\x82̃h\x83\x8D\x83b\x83v\x82͎\x9F\x82̂Ƃ\xB1\x82\xEB\x82Ŕ\xAD\x90\xB6\x82\xB7\x82邱\x82Ƃ\xAA\x8Dl\x82\xA6\x82\xE7\x82\xEA\x82܂\xB7\x81B
+    </p>
+
+    <pre>
+                 s1                   s2                s3                program
+Tera Term ---> Windows ---> (sshd,telnet,pipe) ---> OS,driver      ---> \x8B[\x8E\x97\x92[\x96\x96(pty) + \x83V\x83F\x83\x8B,\x82\xBB\x82̑\xBC\x83R\x83}\x83\x93\x83h
+                            (serial          )      UART\x83`\x83b\x83v\x82Ȃ\xC7      \x91g\x8D\x9E\x83v\x83\x8D\x83O\x83\x89\x83\x80\x93\x99
+         <---          <---                    <---                <---
+                 r1                   r2                r3
+    </pre>
+
+    <dl>
+      <dt>s1 Windows</dt>
+      <dd>\x89”\\x90\xAB\x82͒Ⴂ</dd>
+      <dt>s2 \x91\x97\x90M\x98H</dt>
+      <dd>serial\x82̏ꍇ\x82̓m\x83C\x83Y\x82Ȃǂŕ\xB6\x8E\x9A\x89\xBB\x82\xAF\x81A
+        \x83t\x83\x8D\x81[\x90\xA7\x8C䂪\x8AԂɍ\x87\x82\xED\x82Ȃ\xA2\x93\x99\x82̌\xB4\x88\xF6\x82\xC5
+        \x83h\x83\x8D\x83b\x83v\x82\xB7\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9<br>
+        TCP/IP, pipe\x82̏ꍇ\x82͉”\\x90\xAB\x82͒Ⴂ
+      </dd>
+      <dt>s3 OS,UART\x83`\x83b\x83v</dt>
+      <dd>OS\x83h\x83\x89\x83C\x83o\x82̎\xF3\x90M\x83o\x83b\x83t\x83@\x82̈\xEC\x82\xEA,UART\x83`\x83b\x83v\x82̎\xF3\x90M\x83o\x83b\x83t\x83@\x82̈\xEC\x82\xEA\x82ȂǂŃh\x83\x8D\x83b\x83v\x82\xB7\x82\xE9<br>
+        PC\x82̏\x88\x97\x9D\x94\\x97͂𒴂\xA6\x82\xBD\x83f\x81[\x83^\x82̎\xF3\x90M\x82\xE2\x81Aprogram\x82\xAA\x83f\x81[\x83^\x82\xF0\x88\xF8\x82\xAB\x8E\xE6\x82\xE7\x82Ȃ\xA2\x8Fꍇ\x82Ƀo\x83b\x83t\x83@\x82\xAA\x88\xEC\x82\xEA\x82\xE9
+      </dd>
+      <dt>program</dt>
+      <dd>\x83v\x83\x8D\x83O\x83\x89\x83\x80\x93\xE0\x82̎\xF3\x90M\x83o\x83b\x83t\x83@\x82̈\xEC\x82\xEA\x82ȂǂŃh\x83\x8D\x83b\x83v\x82\xB7\x82\xE9<br>
+        \x89\xBC\x91z\x92[\x96\x96(pty)\x82̃o\x83b\x83t\x83@\x82\xAA\x88\xEC\x82ꂻ\x82\xA4\x82ɂȂ\xE9\x82\xC60x07(BEL)\x82\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAD\x82\xE9
+      </dd>
+    </dl>
+
+    \x8E\xE5\x82\xC8UART\x83`\x83b\x83v\x81A\x83h\x83\x89\x83C\x83o\x82̎\xF3\x90M\x83o\x83b\x83t\x83@\x83T\x83C\x83Y
+    <pre>
+      8250 UART                 \x8E\xF3\x90M\x83o\x83b\x83t\x83@\x82Ȃ\xB5
+      16550 UART                16 Byte FIFO
+      FT232R                    256 Byte receive buffer
+      TTY drive(Linux 2.6.26)   4KB
+    </pre>
+
+
     <h2>"Send file" \x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X(\x91\x97\x90M\x92\x86)</h2>
     <dl>
       <dt>Close</dt>

Modified: branches/sendmem_sendsize/teraterm/common/tt_res.h
===================================================================
--- branches/sendmem_sendsize/teraterm/common/tt_res.h	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/common/tt_res.h	2020-02-11 15:56:16 UTC (rev 8536)
@@ -250,6 +250,12 @@
 #define IDC_SENDFILE_CHECK_BINARY       2597
 #define IDC_SENDFILE_FILENAME_TITLE     2598
 #define IDC_SENDFILE_FILENAME_EDIT      2599
+#define IDC_SENDFILE_DELAYTYPE_LABEL    2600
+#define IDC_SENDFILE_DELAYTYPE_DROPDOWN 2601
+#define IDC_SENDFILE_SEND_SIZE_DROPDOWN 2602
+#define IDC_SENDFILE_SEND_SIZE_LABEL    2603
+#define IDC_SENDFILE_DELAYTIME_LABEL    2604
+#define IDC_SENDFILE_DELAYTIME_EDIT     2605
 #define ID_ACC_SENDBREAK                50001
 #define ID_ACC_COPY                     50002
 #define ID_ACC_NEWCONNECTION            50003
@@ -350,7 +356,7 @@
 #define _APS_NO_MFC                     1
 #define _APS_NEXT_RESOURCE_VALUE        128
 #define _APS_NEXT_COMMAND_VALUE         52031
-#define _APS_NEXT_CONTROL_VALUE         2600
+#define _APS_NEXT_CONTROL_VALUE         2606
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: branches/sendmem_sendsize/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/CMakeLists.txt	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/CMakeLists.txt	2020-02-11 15:56:16 UTC (rev 8536)
@@ -95,6 +95,8 @@
   debug_pp.cpp
   debug_pp.h
   debug_pp.rc
+  sendfiledlg.cpp
+  sendfiledlg.h
   )
 
 target_sources(

Modified: branches/sendmem_sendsize/teraterm/teraterm/clipboar.c
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/clipboar.c	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/clipboar.c	2020-02-11 15:56:16 UTC (rev 8536)
@@ -811,9 +811,12 @@
 	sm = SendMemTextW(str_w, str_len);
 	if (sm == NULL)
 		return;
-	if (ts.PasteDelayPerLine != 0) {
-		SendMemInitDelay(sm, ts.PasteDelayPerLine, 0);
+	if (ts.PasteDelayPerLine == 0) {
+		SendMemInitDelay(sm, SENDMEM_DELAYTYPE_NO_DELAY, 0, 0);
 	}
+	else {
+		SendMemInitDelay(sm, SENDMEM_DELAYTYPE_PER_LINE, ts.PasteDelayPerLine, 0);
+	}
 #if 0
 	SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
 	SendMemInitDialogCaption(sm, L"from clipboard");

Added: branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.cpp
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.cpp	                        (rev 0)
+++ branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.cpp	2020-02-11 15:56:16 UTC (rev 8536)
@@ -0,0 +1,322 @@
+
+#include <windows.h>
+#include <stdio.h>
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#include <wchar.h>
+
+#include "i18n.h"
+#include "tt_res.h"
+#include "ttlib.h"
+#include "dlglib.h"
+#include "layer_for_unicode.h"
+#include "tttypes.h"		// for WM_USER_DLGHELP2
+#include "helpid.h"
+#include "codeconv.h"
+#include "ttftypes.h"		// for TitSendFile
+
+#include "sendfiledlg.h"
+
+/**
+ *	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 = NULL;
+	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);
+	}
+
+	// "\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;
+	{
+		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;
+			}
+		}
+	}
+
+	// \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;
+	}
+
+	if (user_filter_len != 0) {
+		free(user_filter_str);
+	}
+
+	if (len != NULL) {
+		*len = filter_len;
+	}
+	return filter_str;
+}
+
+typedef struct {
+	const char *key;
+	const wchar_t *default_text;
+} I18nTextInfo;
+
+/**
+ *	@param[in]	nsel	0	\x96\xA2\x91I\x91\xF0
+ *						1-	\x91I\x91\xF0\x8D\x80\x96\xDA
+ */
+static
+void SetI18nDropDownList(const char *section, HWND HDlg, int Id_Item, const I18nTextInfo *list, size_t list_size,
+						 const char *UILanguageFile, int nsel)
+{
+	int i;
+	for (i = 0; i < list_size; i++) {
+		wchar_t uimsg[MAX_UIMSG];
+		const I18nTextInfo *p = &list[i];
+		GetI18nStrW(section, p->key, uimsg, _countof(uimsg), p->default_text, UILanguageFile);
+		_SendDlgItemMessageW(HDlg, Id_Item, CB_ADDSTRING, 0, (LPARAM)uimsg);
+	}
+	SendDlgItemMessageA(HDlg, Id_Item, CB_SETCURSEL, nsel - 1, 0);
+}
+
+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"},
+		{IDC_SENDFILE_DELAYTYPE_LABEL, "test"},
+		{IDC_SENDFILE_SEND_SIZE_LABEL, "test"},
+		{IDC_SENDFILE_DELAYTIME_LABEL, "test"},
+		{IDCANCEL, "BTN_CANCEL"},
+		{IDOK, "BTN_OK"},
+	};
+	static const I18nTextInfo l[] = {
+		{"DLG_SENDFILE_DELAYTYPE_NO_DELAY", L"no delay"},
+		{"DLG_SENDFILE_DELAYTYPE_PER_CHAR", L"per charactor"},
+		{"DLG_SENDFILE_DELAYTYPE_PER_LINE", L"per line"},
+		{"DLG_SENDFILE_DELAYTYPE_PER_SENDSIZE", L"per sendsize"},
+	};
+	static const int send_size_list[] = {16, 256, 4 * 1024};
+	sendfiledlgdata *data = (sendfiledlgdata *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	int i;
+
+	switch (msg) {
+		case WM_INITDIALOG:
+			data = (sendfiledlgdata *)lp;
+			data->MsgDlgHelp = RegisterWindowMessage(HELPMSGSTRING);
+			SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
+			::DragAcceptFiles(hDlgWnd, TRUE);
+			SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), data->UILanguageFile);
+			CenterWindow(hDlgWnd, GetParent(hDlgWnd));
+
+			SetI18nDropDownList("TeraTerm", hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, l, _countof(l), data->UILanguageFile, 1);
+
+			for (i = 0; i < _countof(send_size_list); i++) {
+				char buf[32];
+				sprintf(buf, "%d", send_size_list[i]);
+				SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)buf);
+			}
+			SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, CB_SETCURSEL, _countof(send_size_list) - 1, 0);
+
+			SetDlgItemTextA(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT, "1");
+
+			EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), FALSE);
+			EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), 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;
+					data->delay_type = (int)SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0);
+					data->delay_tick = GetDlgItemInt(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT, NULL, FALSE);
+					data->send_size = GetDlgItemInt(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, NULL, 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_s(title, "Tera Term: ");
+					strncat_s(title, _countof(title), uimsg, _TRUNCATE);
+
+					size_t filter_len;
+					wchar_t *filterW = GetCommonDialogFilterW(data->filesend_filter, 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);
+						PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDOK), TRUE);
+					}
+
+					return TRUE;
+				}
+
+				case IDC_SENDFILE_DELAYTYPE_DROPDOWN | (CBN_SELCHANGE << 16): {
+					int sel = (int)SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0);
+					EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), sel != 3 ? FALSE : TRUE);
+					EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), sel == 0 ? FALSE : 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:
+			if (data != NULL && msg == data->MsgDlgHelp) {
+				// \x83R\x83\x82\x83\x93\x83_\x83C\x83A\x83\x8D\x83O\x82Ńw\x83\x8B\x83v\x83{\x83^\x83\x93\x82\xAA\x89\x9F\x82\xB3\x82ꂽ
+				PostMessage(GetParent(hDlgWnd), WM_USER_DLGHELP2, HlpMenuFileSendfile, 0);
+				return TRUE;
+			}
+			return FALSE;
+	}
+}
+
+INT_PTR sendfiledlg(HINSTANCE hInstance, HWND hWndParent, sendfiledlgdata *data)
+{
+	INT_PTR ret;
+	ret = TTDialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SENDFILEDLG), hWndParent, SendFileDlgProc, (LPARAM)data);
+	return ret;
+}

Added: branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.h
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.h	                        (rev 0)
+++ branches/sendmem_sendsize/teraterm/teraterm/sendfiledlg.h	2020-02-11 15:56:16 UTC (rev 8536)
@@ -0,0 +1,27 @@
+
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+	// in
+	const char* UILanguageFile;
+	const char *filesend_filter;
+	// 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
+	int delay_type;
+	DWORD delay_tick;
+	size_t send_size;
+	// work
+	WORD MsgDlgHelp;
+} sendfiledlgdata;
+
+INT_PTR sendfiledlg(HINSTANCE hInstance, HWND hWndParent, sendfiledlgdata *data);
+
+#ifdef __cplusplus
+}
+#endif
+

Modified: branches/sendmem_sendsize/teraterm/teraterm/sendmem.cpp
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/sendmem.cpp	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/sendmem.cpp	2020-02-11 15:56:16 UTC (rev 8536)
@@ -54,7 +54,7 @@
 
 typedef enum {
 	SendMemTypeTextLF,		// wchar_t 0x0a
-	SendMemTypeTextCRLF,	// wchar_t 0x0d + 0x0a
+//	SendMemTypeTextCRLF,	// wchar_t 0x0d + 0x0a
 	SendMemTypeBinary,
 } SendMemType;
 
@@ -69,6 +69,9 @@
 	BOOL send_enable;
 	DWORD delay_per_line;  // (ms)
 	DWORD delay_per_char;
+	DWORD delay_per_sendsize;
+	size_t send_size_max;
+	SendMemDelayType delay_type;
 	HWND hWnd;	 // \x83^\x83C\x83}\x81[\x82\xF0\x8E󂯂\xE9window
 	int timer_id;  // \x83^\x83C\x83}\x81[ID
 	char *UILanguageFile;
@@ -139,6 +142,7 @@
 static void EndPaste()
 {
 	sendmem_work_t *p = sendmem_work;
+	free((void *)p->send_ptr);
 	p->send_ptr = NULL;
 
 	TalkStatus = IdTalkKeyb;
@@ -291,10 +295,12 @@
 
 	// \x91\x97\x90M\x92\xB7
 	BOOL need_delay = FALSE;
+	DWORD delay_tick = 0;
 	size_t send_len;
 	if (p->delay_per_char > 0) {
 		// 1\x83L\x83\x83\x83\x89\x83N\x83^\x91\x97\x90M
 		need_delay = TRUE;
+		delay_tick = p->delay_per_char;
 		if (p->type == SendMemTypeBinary) {
 			send_len = 1;
 		}
@@ -305,6 +311,7 @@
 	else if (p->delay_per_line > 0) {
 		// 1\x83\x89\x83C\x83\x93\x91\x97\x90M
 		need_delay = TRUE;
+		delay_tick = p->delay_per_line;
 
 		// 1\x8Ds\x8E\xE6\x82\xE8\x8Fo\x82\xB5(\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xCD 0x0a \x82ɐ\xB3\x8BK\x89\xBB\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9)
 		const wchar_t *line_top = (wchar_t *)&p->send_ptr[p->send_index];
@@ -326,11 +333,22 @@
 		}
 	}
 	else {
-		// \x91S\x97͑\x97\x90M
 		send_len = p->send_left;
-		if (buff_len < send_len) {
-			send_len = buff_len;
+		if (p->send_size_max == 0) {
+			// \x91S\x97͑\x97\x90M
+			send_len = p->send_left;
+			if (buff_len < send_len) {
+				send_len = buff_len;
+			}
 		}
+		else {
+			// \x91\x97\x90M\x83T\x83C\x83Y\x8F\xE3\x8C\xC0
+			if (send_len > p->send_size_max) {
+				need_delay = TRUE;
+				delay_tick = p->delay_per_sendsize;
+				send_len = p->send_size_max;
+			}
+		}
 	}
 
 	// \x91\x97\x90M\x82\xB7\x82\xE9
@@ -364,8 +382,7 @@
 		p->waited = TRUE;
 		p->last_send_tick = GetTickCount();
 		// \x83^\x83C\x83}\x81[\x82\xCDidle\x82𓮍삳\x82\xB9\x82邽\x82߂Ɏg\x97p\x82\xB5\x82Ă\xA2\x82\xE9
-		const DWORD delay = p->delay_per_line > 0 ? p->delay_per_line : p->delay_per_char;
-		SetTimer(p->hWnd, p->timer_id, delay, NULL);
+		SetTimer(p->hWnd, p->timer_id, delay_tick, NULL);
 	}
 }
 
@@ -433,8 +450,11 @@
 
 	p->type = SendMemTypeBinary;
 	p->local_echo_enable = FALSE;
+	p->delay_type = SENDMEM_DELAYTYPE_NO_DELAY;
+	p->send_size_max = 0;
 	p->delay_per_char = 0;  // (ms)
 	p->delay_per_line = 0;  // (ms)
+	p->delay_per_sendsize = 0;
 	p->cv_ = NULL;
 	p->hWnd = HVTWin;		// delay\x8E\x9E\x82Ɏg\x97p\x82\xB7\x82\xE9\x83^\x83C\x83}\x81[\x97p
 	p->timer_id = IdPasteDelayTimer;
@@ -497,10 +517,34 @@
 	sm->local_echo_enable = echo;
 }
 
-void SendMemInitDelay(SendMem* sm, DWORD per_line, DWORD per_char)
+void SendMemInitDelay(SendMem *sm, SendMemDelayType type, DWORD delay_tick, size_t send_max)
 {
-	sm->delay_per_char = per_char;	// (ms)
-	sm->delay_per_line = per_line;
+	switch (type) {
+	case SENDMEM_DELAYTYPE_NO_DELAY:
+	default:
+		sm->delay_per_char = 0;
+		sm->delay_per_line = 0;
+		sm->send_size_max = 0;
+		break;
+	case SENDMEM_DELAYTYPE_PER_CHAR:
+		sm->delay_per_char = delay_tick;
+		sm->delay_per_line = 0;
+		sm->delay_per_sendsize = 0;
+		sm->send_size_max = 0;
+		break;
+	case SENDMEM_DELAYTYPE_PER_LINE:
+		sm->delay_per_char = 0;
+		sm->delay_per_line = delay_tick;
+		sm->delay_per_sendsize = 0;
+		sm->send_size_max = 0;
+		break;
+	case SENDMEM_DELAYTYPE_PER_SENDSIZE:
+		sm->delay_per_char = 0;
+		sm->delay_per_line = 0;
+		sm->delay_per_sendsize = delay_tick;
+		sm->send_size_max = send_max;
+		break;
+	}
 }
 
 // \x83Z\x83b\x83g\x82\xB7\x82\xE9\x82ƃ_\x83C\x83A\x83\x8D\x83O\x82\xAA\x8Fo\x82\xE9
@@ -570,7 +614,7 @@
 	return TRUE;
 }
 #else
-BOOL SendMemSendFile(const wchar_t *filename, BOOL binary)
+BOOL SendMemSendFile(const wchar_t *filename, BOOL binary, SendMemDelayType delay_type, DWORD delay_tick, size_t send_max)
 {
 	SendMem *sm;
 	if (!binary) {
@@ -592,6 +636,7 @@
 	SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
 	SendMemInitDialogCaption(sm, L"send file");			// title
 	SendMemInitDialogFilename(sm, filename);
+	SendMemInitDelay(sm, delay_type, delay_tick, send_max);
 	SendMemStart(sm);
 	return TRUE;
 }

Modified: branches/sendmem_sendsize/teraterm/teraterm/sendmem.h
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/sendmem.h	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/sendmem.h	2020-02-11 15:56:16 UTC (rev 8536)
@@ -35,10 +35,17 @@
 
 typedef struct SendMemTag SendMem;
 
+typedef enum {
+	SENDMEM_DELAYTYPE_NO_DELAY,
+	SENDMEM_DELAYTYPE_PER_CHAR,
+	SENDMEM_DELAYTYPE_PER_LINE,
+	SENDMEM_DELAYTYPE_PER_SENDSIZE,
+} SendMemDelayType;
+
 SendMem *SendMemTextW(wchar_t *ptr, size_t len);
 SendMem *SendMemBinary(void *ptr, size_t len);
 void SendMemInitEcho(SendMem *sm, BOOL echo);
-void SendMemInitDelay(SendMem *sm, DWORD per_line, DWORD per_char);
+void SendMemInitDelay(SendMem *sm, SendMemDelayType delay_type, DWORD delay_tick, size_t send_max);
 void SendMemInitDialog(SendMem *sm, HINSTANCE hInstance, HWND hWndParent, const char *UILanguageFile);
 void SendMemInitDialogCaption(SendMem *sm, const wchar_t *caption);
 void SendMemInitDialogFilename(SendMem *sm, const wchar_t *filename);
@@ -45,10 +52,6 @@
 BOOL SendMemStart(SendMem *sm);		// \x91\x97\x90M\x8AJ\x8En
 void SendMemFinish(SendMem *sm);
 
-// convenient function
-BOOL SendMemSendFile(const wchar_t *filename, BOOL binary);
-BOOL SendMemPasteString(wchar_t *str);
-
 // idle\x82\xA9\x82\xE7\x82̑\x97\x90M\x97pAPI
 void SendMemContinuously(void);
 
@@ -56,3 +59,8 @@
 }
 #endif
 
+#ifdef __cplusplus
+// convenient function
+BOOL SendMemSendFile(const wchar_t *filename, BOOL binary, SendMemDelayType delay_type = SENDMEM_DELAYTYPE_NO_DELAY, DWORD delay_tick = 0, size_t send_max = 0);
+BOOL SendMemPasteString(wchar_t *str);
+#endif

Modified: branches/sendmem_sendsize/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/ttermpro.rc	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/ttermpro.rc	2020-02-11 15:56:16 UTC (rev 8536)
@@ -353,18 +353,24 @@
     EDITTEXT        IDC_SSH_SETUPDIR_EDIT_VSTORE,68,179,251,14,ES_AUTOHSCROLL | ES_READONLY
 END
 
-IDD_SENDFILEDLG DIALOGEX 0, 0, 271, 83
+IDD_SENDFILEDLG DIALOGEX 0, 0, 271, 182
 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
+    LTEXT           "&Filename (drop file in this dialog)",IDC_SENDFILE_FILENAME_TITLE,9,7,172,8
+    EDITTEXT        IDC_SENDFILE_FILENAME_EDIT,18,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
+    CONTROL         "&Binary",IDC_SENDFILE_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,44,72,10
+    LTEXT           "delay type",IDC_SENDFILE_DELAYTYPE_LABEL,9,61,74,11
+    COMBOBOX        IDC_SENDFILE_DELAYTYPE_DROPDOWN,18,75,64,53,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    LTEXT           "send size(bytes)",IDC_SENDFILE_SEND_SIZE_LABEL,9,92,75,8
+    COMBOBOX        IDC_SENDFILE_SEND_SIZE_DROPDOWN,18,106,65,47,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    LTEXT           "delay time(ms)",IDC_SENDFILE_DELAYTIME_LABEL,9,124,75,8
+    EDITTEXT        IDC_SENDFILE_DELAYTIME_EDIT,18,139,40,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "Help",IDHELP,104,160,50,14
+    DEFPUSHBUTTON   "OK",IDOK,160,160,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,215,160,50,14
 END
 
 
@@ -471,6 +477,13 @@
         TOPMARGIN, 7
         BOTTOMMARGIN, 204
     END
+
+    IDD_SENDFILEDLG, DIALOG
+    BEGIN
+        VERTGUIDE, 9
+        VERTGUIDE, 18
+        BOTTOMMARGIN, 174
+    END
 END
 #endif    // APSTUDIO_INVOKED
 

Modified: branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj	2020-02-11 15:56:16 UTC (rev 8536)
@@ -163,6 +163,7 @@
     <ClCompile Include="filesys.cpp" />
     <ClCompile Include="ftdlg.cpp" />
     <ClCompile Include="keyboard.c" />
+    <ClCompile Include="sendfiledlg.cpp" />
     <ClCompile Include="sizetip.c" />
     <ClCompile Include="prnabort.cpp" />
     <ClCompile Include="protodlg.cpp" />
@@ -190,6 +191,7 @@
     <ClInclude Include="../ttpdlg/ttdlg.h" />
     <ClInclude Include="../ttpmacro/fileread.h" />
     <ClCompile Include="../ttpmacro/fileread.cpp" />
+    <ClInclude Include="sendfiledlg.h" />
     <ClInclude Include="sendmem.h" />
     <ClCompile Include="sendmem.cpp" />
     <ClInclude Include="ftdlg_lite.h" />

Modified: branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj.filters
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj.filters	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/ttermpro.v16.vcxproj.filters	2020-02-11 15:56:16 UTC (rev 8536)
@@ -168,6 +168,9 @@
     <ClCompile Include="ftdlg_lite.cpp">
       <Filter>dialog</Filter>
     </ClCompile>
+    <ClCompile Include="sendfiledlg.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="..\..\cygterm\cygterm.ico">
@@ -369,5 +372,8 @@
     <ClInclude Include="ftdlg_lite.h">
       <Filter>dialog</Filter>
     </ClInclude>
+    <ClInclude Include="sendfiledlg.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file

Modified: branches/sendmem_sendsize/teraterm/teraterm/ttermpro.vcproj
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/ttermpro.vcproj	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/ttermpro.vcproj	2020-02-11 15:56:16 UTC (rev 8536)
@@ -237,6 +237,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\sendfiledlg.cpp"
+				>
+			</File>
+			<File
 				RelativePath="tekwin.cpp"
 				>
 			</File>
@@ -431,6 +435,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\sendfiledlg.h"
+				>
+			</File>
+			<File
 				RelativePath="sizetip.h"
 				>
 			</File>

Modified: branches/sendmem_sendsize/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/sendmem_sendsize/teraterm/teraterm/vtwin.cpp	2020-02-11 15:52:13 UTC (rev 8535)
+++ branches/sendmem_sendsize/teraterm/teraterm/vtwin.cpp	2020-02-11 15:56:16 UTC (rev 8536)
@@ -93,6 +93,7 @@
 #include "codeconv.h"
 #include "layer_for_unicode.h"
 #include "sendmem.h"
+#include "sendfiledlg.h"
 
 #include "initguid.h"
 //#include "Usbiodef.h"
@@ -4232,258 +4233,6 @@
 	}
 }
 
-/**
- *	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 = NULL;
-	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);
-	}
-
-	// "\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;
-	{
-		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;
-			}
-		}
-	}
-
-	// \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;
-	}
-
-	if (user_filter_len != 0) {
-		free(user_filter_str);
-	}
-
-	if (len != NULL) {
-		*len = filter_len;
-	}
-	return filter_str;
-}
-
-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;
-
-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));
-			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_s(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
@@ -4494,7 +4243,7 @@
 				  ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT");
 	sendfiledlgdata data;
 	data.UILanguageFile = ts.UILanguageFile;
-	data.MsgDlgHelp = RegisterWindowMessage(HELPMSGSTRING);
+	data.filesend_filter = ts.FileSendFilter;
 	INT_PTR ok = sendfiledlg(m_hInst, m_hWnd, &data);
 	if (ok != IDOK) {
 		return;
@@ -4501,7 +4250,7 @@
 	}
 
 	wchar_t *filename = data.filename;
-	SendMemSendFile(filename, data.binary);
+	SendMemSendFile(filename, data.binary, (SendMemDelayType)data.delay_type, data.delay_tick, data.send_size);
 	free(filename);
 #endif
 }


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