• 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

修订版685d31d4ff178c08ee26df2c6cf73755a9ae879a (tree)
时间2020-03-28 00:52:34
作者zmatsuo <zmatsuo@user...>
Commiterzmatsuo

Log Message

ホスト名のドロップダウンの横幅を広くできるようにした

- ExpandCBWidth()追加
- SSHバージョン,IPバージョンの設定判定処理を文字列から数値(インデックス)に変更した

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

更改概述

差异

--- a/ttssh2/ttxssh/ttxssh.c
+++ b/ttssh2/ttxssh/ttxssh.c
@@ -58,7 +58,6 @@
5858 #include <commctrl.h>
5959 #include <commdlg.h>
6060 #include <winsock2.h>
61-static char *ProtocolFamilyList[] = { "AUTO", "IPv6", "IPv4", NULL };
6261
6362 #include <lmcons.h>
6463
@@ -1291,6 +1290,35 @@ LRESULT CALLBACK HostnameEditProc(HWND dlg, UINT msg,
12911290 return CallWindowProc(OrigHostnameEditProc, dlg, msg, wParam, lParam);
12921291 }
12931292
1293+/**
1294+ * リストの横幅を拡張する(元の幅より狭くなることはない)
1295+ * @param[in] dlg ダイアログのハンドル
1296+ * @param[in] ID コンボボックスのID
1297+ */
1298+static void ExpandCBWidth(HWND dlg, int ID)
1299+{
1300+ HWND hCtrlWnd = GetDlgItem(dlg, ID);
1301+ int count = (int)SendMessage(hCtrlWnd, CB_GETCOUNT, 0, 0);
1302+ HFONT hFont = (HFONT)SendMessage(hCtrlWnd, WM_GETFONT, 0, 0);
1303+ int i, max_width = 0;
1304+ HDC TmpDC = GetDC(hCtrlWnd);
1305+ hFont = (HFONT)SelectObject(TmpDC, hFont);
1306+ for (i=0; i<count; i++) {
1307+ SIZE s;
1308+ int len = (int)SendMessage(hCtrlWnd, CB_GETLBTEXTLEN, i, 0);
1309+ char *lbl = (char *)calloc(len+1, sizeof(char));
1310+ SendMessage(hCtrlWnd, CB_GETLBTEXT, i, (LPARAM)lbl);
1311+ GetTextExtentPoint32(TmpDC, lbl, len, &s);
1312+ if (s.cx > max_width)
1313+ max_width = s.cx;
1314+ free(lbl);
1315+ }
1316+ max_width += GetSystemMetrics(SM_CXVSCROLL); // スクロールバーの幅も足し込んでおく
1317+ SendMessage(hCtrlWnd, CB_SETDROPPEDWIDTH, max_width, 0);
1318+ SelectObject(TmpDC, hFont);
1319+ ReleaseDC(hCtrlWnd, TmpDC);
1320+}
1321+
12941322 static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
12951323 LPARAM lParam)
12961324 {
@@ -1310,6 +1338,7 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
13101338 { IDCANCEL, "BTN_CANCEL" },
13111339 };
13121340 static char *ssh_version[] = {"SSH1", "SSH2", NULL};
1341+ static char *ProtocolFamilyList[] = { "AUTO", "IPv6", "IPv4", NULL };
13131342 PGetHNRec GetHNRec;
13141343 char EntName[128];
13151344 char TempHost[HostNameMaxLength + 1];
@@ -1482,6 +1511,8 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
14821511 SetFocus(hwnd);
14831512 }
14841513
1514+ ExpandCBWidth(dlg, IDC_HOSTNAME);
1515+ ExpandCBWidth(dlg, IDC_HOSTCOM);
14851516 CenterWindow(dlg, GetParent(dlg));
14861517
14871518 // SetFocus()でフォーカスをあわせた場合、FALSEを返す必要がある。
@@ -1497,7 +1528,6 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
14971528 if (GetHNRec != NULL) {
14981529 if (IsDlgButtonChecked(dlg, IDC_HOSTTCPIP)) {
14991530 BOOL Ok;
1500- char afstr[BUFSIZ];
15011531 i = GetDlgItemInt(dlg, IDC_HOSTTCPPORT, &Ok, FALSE);
15021532 if (!Ok) {
15031533 // TODO IDC_HOSTTCPPORTは数値しか入力できない、不要?
@@ -1510,13 +1540,10 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
15101540 return TRUE;
15111541 }
15121542 GetHNRec->TCPPort = i;
1513-#define getaf(str) \
1514-((strcmp((str), "IPv6") == 0) ? AF_INET6 : \
1515- ((strcmp((str), "IPv4") == 0) ? AF_INET : AF_UNSPEC))
1516- memset(afstr, 0, sizeof(afstr));
1517- GetDlgItemText(dlg, IDC_HOSTTCPPROTOCOL, afstr,
1518- sizeof(afstr));
1519- GetHNRec->ProtocolFamily = getaf(afstr);
1543+ i = (int)SendDlgItemMessage(dlg, IDC_HOSTTCPPROTOCOL, CB_GETCURSEL, 0, 0);
1544+ GetHNRec->ProtocolFamily =
1545+ i == 0 ? AF_UNSPEC :
1546+ i == 1 ? AF_INET6 : AF_INET;
15201547 GetHNRec->PortType = IdTCPIP;
15211548 GetDlgItemText(dlg, IDC_HOSTNAME, GetHNRec->HostName,
15221549 HostNameMaxLength);
@@ -1528,13 +1555,8 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
15281555 pvar->hostdlg_Enabled = TRUE;
15291556
15301557 // check SSH protocol version
1531- memset(afstr, 0, sizeof(afstr));
1532- GetDlgItemText(dlg, IDC_SSH_VERSION, afstr, sizeof(afstr));
1533- if (_stricmp(afstr, "SSH1") == 0) {
1534- pvar->settings.ssh_protocol_version = 1;
1535- } else {
1536- pvar->settings.ssh_protocol_version = 2;
1537- }
1558+ i = (int)SendDlgItemMessage(dlg, IDC_SSH_VERSION, CB_GETCURSEL, 0, 0);
1559+ pvar->settings.ssh_protocol_version = (i == 0) ? 1 : 2;
15381560 }
15391561 else { // IDC_HOSTOTHER
15401562 GetHNRec->Telnet = FALSE;
@@ -1623,28 +1645,6 @@ hostssh_enabled:
16231645 }
16241646 return TRUE;
16251647
1626- case IDC_HOSTCOM:
1627- if(HIWORD(wParam) == CBN_DROPDOWN) {
1628- HWND hostcom = GetDlgItem(dlg, IDC_HOSTCOM);
1629- int count = SendMessage(hostcom, CB_GETCOUNT, 0, 0);
1630- int i, len, max_len = 0;
1631- char *lbl;
1632- HDC TmpDC = GetDC(hostcom);
1633- SIZE s;
1634- for (i=0; i<count; i++) {
1635- len = SendMessage(hostcom, CB_GETLBTEXTLEN, i, 0);
1636- lbl = (char *)calloc(len+1, sizeof(char));
1637- SendMessage(hostcom, CB_GETLBTEXT, i, (LPARAM)lbl);
1638- GetTextExtentPoint32(TmpDC, lbl, len, &s);
1639- if (s.cx > max_len)
1640- max_len = s.cx;
1641- free(lbl);
1642- }
1643- SendMessage(hostcom, CB_SETDROPPEDWIDTH,
1644- max_len + GetSystemMetrics(SM_CXVSCROLL), 0);
1645- }
1646- break;
1647-
16481648 case IDC_HOSTHELP:
16491649 PostMessage(GetParent(dlg), WM_USER_DLGHELP2, HlpFileNewConnection, 0);
16501650 }