From 0200a36062386b937567265e3ea01f93eaa8f1f5 Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期五, 20 十月 2023 22:10:19 +0800
Subject: [PATCH] dev1

---
 KLink1/CDialogCommSet1.cpp |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/KLink1/CDialogCommSet1.cpp b/KLink1/CDialogCommSet1.cpp
index 44249b5..fb57d19 100644
--- a/KLink1/CDialogCommSet1.cpp
+++ b/KLink1/CDialogCommSet1.cpp
@@ -101,13 +101,19 @@
 	for (int i = 1; i <= 16; i++)
 	{
 		s1.Format(_T("COM%d"), i);
-		if (get_com_name(s1, s2)) s1 = s2;
+		if (get_com_name(s1 + _T(")"), s2)) { s1 = s2; }
 		m_combo_comport.AddString(s1);
 	}
-	sComSelStr = _T("COM3");
-	m_combo_comport.SelectString(0, sComSelStr);
-	m_combo_comport.SetCurSel(2);
+	// sComSelStr = _T("COM3");
+	// m_combo_comport.SelectString(0, sComSelStr);
+	// m_combo_comport.SetCurSel(2);
+	if (m_nComNum >0)
+		m_combo_comport.SetCurSel(m_nComNum - 1);
+	else {
+		m_combo_comport.SetCurSel(0);
+	}
 	return 0;
+
 	HKEY   hKey;
 	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Hardware\\DeviceMap\\SerialComm"), NULL, KEY_READ, &hKey) == ERROR_SUCCESS)
 	{
@@ -151,7 +157,7 @@
 	// TODO: 鍦ㄦ澶勬坊鍔犲疄鐜颁唬鐮�.
 	((CComboBox *)GetDlgItem(IDC_COMBO_NETWORK_TYPE))->SetCurSel(0);
 	((CComboBox *)GetDlgItem(IDC_COMBO_PORT))->SetCurSel(0);
-	((CComboBox *)GetDlgItem(IDC_COMBO_BAUD))->SetCurSel(8);
+	((CComboBox *)GetDlgItem(IDC_COMBO_BAUD))->SetCurSel(7);
 
 	((CButton *)GetDlgItem(IDC_RADIO_DATA_LENGTH_8B))->SetCheck(1);
 
@@ -165,6 +171,10 @@
 	((CButton *)GetDlgItem(IDC_CHECK_AUTO_PARITY))->SetCheck(1);
 
 	UpdateComPortList();
+
+	CString s1;
+	if (m_bOpened) s1 = _T("宸茶繛鎺�"); else s1 = _T("鏈繛鎺�");
+	((CStatic*)GetDlgItem(IDC_STATIC_STATE))->SetWindowText(s1);
 	return 0;
 }
 

--
Gitblit v1.9.1