[ttssh2-commit] [9484] 接続履歴をコンボボックスにセットする関数を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 10月 23日 (土) 01:09:09 JST


Revision: 9484
          https://osdn.net/projects/ttssh2/scm/svn/commits/9484
Author:   zmatsuo
Date:     2021-10-23 01:09:09 +0900 (Sat, 23 Oct 2021)
Log Message:
-----------
接続履歴をコンボボックスにセットする関数を追加

- SetComboBoxHostHistory()

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

-------------- next part --------------
Modified: trunk/teraterm/common/dlglib.h
===================================================================
--- trunk/teraterm/common/dlglib.h	2021-10-22 16:08:58 UTC (rev 9483)
+++ trunk/teraterm/common/dlglib.h	2021-10-22 16:09:09 UTC (rev 9484)
@@ -95,6 +95,7 @@
 wchar_t *GetCommonDialogFilterWW(const char *user_filter_mask, const wchar_t *UILanguageFile);
 wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile);
 void SetDlgItemIcon(HWND dlg, int nID, const wchar_t *name, int cx, int cy);
+void SetComboBoxHostHistory(HWND dlg, int dlg_item, int maxhostlist, const wchar_t *SetupFNW);
 
 #ifdef __cplusplus
 }

Modified: trunk/teraterm/common/dlglib_cpp.cpp
===================================================================
--- trunk/teraterm/common/dlglib_cpp.cpp	2021-10-22 16:08:58 UTC (rev 9483)
+++ trunk/teraterm/common/dlglib_cpp.cpp	2021-10-22 16:09:09 UTC (rev 9484)
@@ -42,6 +42,7 @@
 #include "codeconv.h"
 #include "asprintf.h"
 #include "compat_win.h"
+#include "win32helper.h"
 
 /**
  *	EndDialog() \x8C݊\xB7\x8A֐\x94
@@ -453,3 +454,23 @@
 	data->prev_proc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)IconProc);
 	SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)data);
 }
+
+/**
+ *	\x90ڑ\xB1\x82\xB5\x82\xBD\x83z\x83X\x83g\x97\x9A\x97\xF0\x82\xF0\x83R\x83\x93\x83{\x83{\x83b\x83N\x83X\x82ɃZ\x83b\x83g\x82\xB7\x82\xE9
+ */
+void SetComboBoxHostHistory(HWND dlg, int dlg_item, int maxhostlist, const wchar_t *SetupFNW)
+{
+	int i = 1;
+	do {
+		wchar_t EntNameW[128];
+		wchar_t *TempHostW;
+		_snwprintf_s(EntNameW, _countof(EntNameW), _TRUNCATE, L"host%d", i);
+		hGetPrivateProfileStringW(L"Hosts", EntNameW, L"", SetupFNW, &TempHostW);
+		if (TempHostW[0] != 0) {
+			SendDlgItemMessageW(dlg, dlg_item, CB_ADDSTRING,
+								0, (LPARAM) TempHostW);
+		}
+		free(TempHostW);
+		i++;
+	} while (i <= maxhostlist);
+}

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2021-10-22 16:08:58 UTC (rev 9483)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2021-10-22 16:09:09 UTC (rev 9484)
@@ -1848,7 +1848,6 @@
 	};
 	PGetHNRec GetHNRec;
 	char EntName[128];
-	char TempHost[HostNameMaxLength+1];
 	WORD i, j, w;
 	BOOL Ok;
 	WORD ComPortTable[MAXCOMPORT];
@@ -1869,17 +1868,8 @@
 				GetHNRec->PortType = IdTCPIP;
 			}
 
-			i = 1;
-			do {
-				_snprintf_s(EntName, sizeof(EntName), _TRUNCATE, "Host%d", i);
-				GetPrivateProfileString("Hosts",EntName,"",
-				                        TempHost,sizeof(TempHost),GetHNRec->SetupFN);
-				if ( strlen(TempHost) > 0 ) {
-					SendDlgItemMessage(Dialog, IDC_HOSTNAME, CB_ADDSTRING,
-					                   0, (LPARAM)TempHost);
-				}
-				i++;
-			} while (i <= MAXHOSTLIST);
+			SetComboBoxHostHistory(Dialog, IDC_HOSTNAME, MAXHOSTLIST, GetHNRec->SetupFNW);
+			ExpandCBWidth(Dialog, IDC_HOSTNAME);
 
 			SendDlgItemMessage(Dialog, IDC_HOSTNAME, EM_LIMITTEXT,
 			                   HostNameMaxLength-1, 0);

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2021-10-22 16:08:58 UTC (rev 9483)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2021-10-22 16:09:09 UTC (rev 9484)
@@ -1046,21 +1046,7 @@
 			)
 			GetHNRec->PortType = IdTCPIP;
 
-		{
-			i = 1;
-			do {
-				wchar_t EntNameW[128];
-				wchar_t *TempHostW;
-				_snwprintf_s(EntNameW, _countof(EntNameW), _TRUNCATE, L"host%d", i);
-				hGetPrivateProfileStringW(L"Hosts", EntNameW, L"", GetHNRec->SetupFNW, &TempHostW);
-				if (TempHostW[0] != 0) {
-					SendDlgItemMessageW(dlg, IDC_HOSTNAME, CB_ADDSTRING,
-										0, (LPARAM) TempHostW);
-				}
-				free(TempHostW);
-				i++;
-			} while (i <= MAXHOSTLIST);
-		}
+		SetComboBoxHostHistory(dlg, IDC_HOSTNAME, MAXHOSTLIST, GetHNRec->SetupFNW);
 
 		SendDlgItemMessage(dlg, IDC_HOSTNAME, EM_LIMITTEXT,
 		                   HostNameMaxLength - 1, 0);


ttssh2-commit メーリングリストの案内
Back to archive index