• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

Tera Termの個人的な作業用リポジトリ


Commit MetaInfo

修订版06804ff35c164d37452204c3e9e215bc2eda897c (tree)
时间2020-03-24 00:54:48
作者zmatsuo <zmatsuo@user...>
Commiterzmatsuo

Log Message

ファイル送信ダイアログのファイルオープンを layer for unicode 版に置き換え

- ファイルヘッダを付けていなかったので追加

git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk@8618 f5f01b69-1e22-0410-acbf-894ab4bd6246

更改概述

差异

--- a/teraterm/teraterm/sendfiledlg.cpp
+++ b/teraterm/teraterm/sendfiledlg.cpp
@@ -1,3 +1,30 @@
1+/*
2+ * (C) 2020 TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
128
229 #include <windows.h>
330 #include <stdio.h>
@@ -15,6 +42,7 @@
1542 #include "helpid.h"
1643 #include "codeconv.h"
1744 #include "ttftypes.h" // for TitSendFile
45+#include "asprintf.h"
1846
1947 #include "sendfiledlg.h"
2048
@@ -160,24 +188,15 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
160188 case WM_COMMAND:
161189 switch (wp) {
162190 case IDOK | (BN_CLICKED << 16): {
163- size_t len = _SendDlgItemMessageW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, WM_GETTEXTLENGTH, 0, 0);
164- len++; // for '\0'
165- wchar_t *strW = (wchar_t *)malloc(sizeof(wchar_t) * len);
166- if (strW != NULL) {
167- _GetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, strW, (int)len);
168- strW[len - 1] = '\0';
169- }
191+ wchar_t *strW = AllocControlTextW(GetDlgItem(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT));
170192
171193 const DWORD attr = _GetFileAttributesW(strW);
172194 if (attr == INVALID_FILE_ATTRIBUTES || attr & FILE_ATTRIBUTE_DIRECTORY) {
173- wchar_t caption[MAX_UIMSG];
174- wchar_t message[MAX_UIMSG];
175-
176- get_lang_msgW("MSG_TT_ERROR", caption, _countof(caption), L"Tera Term: Error",
177- data->UILanguageFile);
178- get_lang_msgW("MSG_CANTOPEN_FILE_ERROR", message, _countof(message), L"Cannot open file",
179- data->UILanguageFile);
180- _MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION);
195+ static const TTMessageBoxInfoW mbinfo = {
196+ "Tera Term",
197+ "MSG_TT_ERROR", L"Tera Term: Error",
198+ "MSG_CANTOPEN_FILE_ERROR", L"Cannot open file" };
199+ TTMessageBoxW(hDlgWnd, &mbinfo, MB_TASKMODAL | MB_ICONEXCLAMATION, data->UILanguageFile);
181200
182201 free(strW);
183202
@@ -210,40 +229,38 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
210229 return TRUE;
211230
212231 case IDC_SENDFILE_FILENAME_BUTTON | (BN_CLICKED << 16): {
213- char TempDir[MAX_PATH];
214- GetCurrentDirectoryA(sizeof(TempDir), TempDir);
232+ wchar_t TempDir[MAX_PATH];
233+ _GetCurrentDirectoryW(_countof(TempDir), TempDir);
215234
216- char title[40];
217- char uimsg[MAX_UIMSG];
218- get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile,
219- data->UILanguageFile);
220- strcpy_s(title, "Tera Term: ");
221- strncat_s(title, _countof(title), uimsg, _TRUNCATE);
235+#define TitSendFileW L"Send file"
236+ wchar_t *uimsg = TTGetLangStrW("Tera Term", "FILEDLG_TRANS_TITLE_SENDFILE", TitSendFileW, data->UILanguageFile);
237+ wchar_t *title;
238+ aswprintf(&title, L"Tera Term: %s", uimsg);
239+ free(uimsg);
240+ uimsg = NULL;
222241
223242 size_t filter_len;
224243 wchar_t *filterW = GetCommonDialogFilterW(data->filesend_filter, data->UILanguageFile, &filter_len);
225- char *filterA = _WideCharToMultiByte(filterW, filter_len, CP_ACP, NULL);
226- free(filterW);
227244
228- char filename[MAX_PATH];
245+ wchar_t filename[MAX_PATH];
229246 filename[0] = 0;
230- OPENFILENAME ofn = {};
231- ofn.lStructSize = get_OPENFILENAME_SIZE();
247+ OPENFILENAMEW ofn = {};
248+ ofn.lStructSize = get_OPENFILENAME_SIZEW();
232249 ofn.hwndOwner = hDlgWnd;
233250 ofn.lpstrFile = filename;
234- ofn.nMaxFile = sizeof(filename);
235251 ofn.nMaxFile = MAX_PATH;
236- ofn.lpstrFilter = filterA;
252+ ofn.lpstrFilter = filterW;
237253 ofn.nFilterIndex = 0;
238254 ofn.lpstrTitle = title;
239255 ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY;
240- BOOL Ok = GetOpenFileNameA(&ofn);
241- free(filterA);
256+ BOOL Ok = _GetOpenFileNameW(&ofn);
257+ free(filterW);
258+ free(title);
242259
243- SetCurrentDirectoryA(TempDir);
260+ _SetCurrentDirectoryW(TempDir);
244261
245262 if (Ok) {
246- SetDlgItemTextA(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, filename);
263+ _SetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, filename);
247264 PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDOK), TRUE);
248265 }
249266
--- a/teraterm/teraterm/sendfiledlg.h
+++ b/teraterm/teraterm/sendfiledlg.h
@@ -1,4 +1,32 @@
1+/*
2+ * (C) 2020 TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
128
29+#pragma once
230 #include <windows.h>
331
432 #ifdef __cplusplus