From 417d3825013cd1b9e8a8dafa72f51c755ee5d897 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 23 六月 2025 15:20:32 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/resource.h     |    0 
 SourceCode/Bond/Servo/Servo.rc       |    0 
 SourceCode/Bond/Servo/PageRecipe.h   |    4 
 SourceCode/Bond/Servo/PageRecipe.cpp |  148 +++++++++++++++++++++++-------------------------
 4 files changed, 73 insertions(+), 79 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 468bc34..939ab8f 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -53,8 +53,6 @@
 {
 	CDialogEx::DoDataExchange(pDX);
 	DDX_Control(pDX, IDC_LIST_PPID, m_listPPID);
-	DDX_Control(pDX, IDC_EDIT_PPID, m_editPPID);
-	DDX_Control(pDX, IDC_EDIT_DESC, m_editDesc);
 }
 
 
@@ -66,6 +64,7 @@
 	ON_BN_CLICKED(IDC_BUTTON_DELETE_ALL, &CPageRecipe::OnBnClickedButtonDeleteAll)
 	ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CPageRecipe::OnBnClickedButtonRefresh)
 	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PPID, &CPageRecipe::OnLvnItemChangedListPPID)
+	ON_WM_DESTROY()
 END_MESSAGE_MAP()
 
 
@@ -74,6 +73,16 @@
 BOOL CPageRecipe::OnInitDialog()
 {
 	CDialogEx::OnInitDialog();
+
+	// 璇诲嚭鍒楀
+	CString strIniFile, strItem;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	int width[8] = { 0, 80, 180, 80, 80, 100, 80, 180 };
+	for (int i = 0; i < 8; i++) {
+		strItem.Format(_T("Col_%d_Width"), i);
+		width[i] = GetPrivateProfileInt("PageRecipeListCtrl", strItem, width[i], strIniFile);
+	}
+
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
 	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
@@ -85,10 +94,10 @@
 	HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
 	ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
 	pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); // 闅愯棌鍒�
-	pListCtrl->InsertColumn(1, _T("No."), LVCFMT_LEFT, 80);
-	pListCtrl->InsertColumn(2, _T("PPID"), LVCFMT_LEFT, 120);
-	pListCtrl->InsertColumn(3, _T("鎻忚堪"), LVCFMT_LEFT, 180);
-	pListCtrl->InsertColumn(4, _T("鍒涘缓鏃堕棿"), LVCFMT_LEFT, 160);
+	pListCtrl->InsertColumn(1, _T("No."), LVCFMT_LEFT, width[1]);
+	pListCtrl->InsertColumn(2, _T("PPID"), LVCFMT_LEFT, width[2]);
+	pListCtrl->InsertColumn(3, _T("鎻忚堪"), LVCFMT_LEFT, width[3]);
+	pListCtrl->InsertColumn(4, _T("鍒涘缓鏃堕棿"), LVCFMT_LEFT, width[4]);
 	pListCtrl->SetColumnWidth(4, LVSCW_AUTOSIZE_USEHEADER);
 
 	// 鑾峰彇鎵�鏈夋暟鎹�
@@ -103,85 +112,58 @@
 {
 	CDialogEx::OnSize(nType, cx, cy);
 
-	if (m_listPPID.GetSafeHwnd()) {
-		// 宸︿晶鍒楄〃瀹介珮鑷�傚簲
-		int margin = 10;
-		int buttonWidth = 80;
-		int buttonHeight = 30;
-		int buttonSpacing = 10;
+	if (!m_listPPID.GetSafeHwnd())
+		return;
 
-		CRect rect;
-		GetClientRect(&rect);
 
-		int listWidth = rect.Width() - buttonWidth - 3 * margin;
-		int listHeight = rect.Height() - 2 * margin;
+	// 宸︿晶鍒楄〃瀹介珮鑷�傚簲
+	int margin = 12;
+	int buttonWidth = 80;
+	int buttonHeight = 30;
+	int buttonSpacing = 10;
 
-		m_listPPID.MoveWindow(margin, margin + 80, listWidth, listHeight - 80);
+	CWnd* pItem;
+	CRect rect, rcItem;
+	GetClientRect(&rect);
 
-		// 缂栬緫妗嗚皟鏁翠綅缃細鍙宠竟瀵归綈鍒楄〃锛屽乏杈瑰浐瀹氳捣濮�
-		int labelWidth = 60;
-		int rightEdge = rect.right - buttonWidth - 2 * margin;
+	pItem = GetDlgItem(IDC_EDIT_KEYWORD);
+	ASSERT(pItem);
+	pItem->GetWindowRect(rcItem);
+	ScreenToClient(&rcItem);
 
-		if (m_editPPID.GetSafeHwnd()) {
-			m_editPPID.MoveWindow(labelWidth, margin, rightEdge - labelWidth, 25);
+	int y = rcItem.bottom;
+	y += 12;
+	int listWidth = rect.Width() - buttonWidth - 3 * margin;
+	m_listPPID.MoveWindow(margin, y, listWidth, rect.bottom - 12 - y);
+
+
+	// 鎸夐挳绔栫洿鎺掑垪鍦ㄥ彸渚�
+	CWnd* buttons[] = {
+		GetDlgItem(IDC_BUTTON_MODIFY),
+		GetDlgItem(IDC_BUTTON_DELETE),
+		GetDlgItem(IDC_BUTTON_DELETE_ALL),
+		GetDlgItem(IDC_BUTTON_REFRESH)
+	};
+
+	for (auto pBtn : buttons) {
+		if (pBtn && pBtn->GetSafeHwnd()) {
+			pBtn->MoveWindow(rect.right - buttonWidth - margin, y, buttonWidth, buttonHeight);
+			y += buttonHeight + buttonSpacing;
 		}
-		if (m_editDesc.GetSafeHwnd()) {
-			m_editDesc.MoveWindow(labelWidth, margin + 35, rightEdge - labelWidth, 25);
-		}
-
-		// 鎸夐挳绔栫洿鎺掑垪鍦ㄥ彸渚�
-		CWnd* buttons[] = {
-			GetDlgItem(IDC_BUTTON_SEARCH),
-			GetDlgItem(IDC_BUTTON_MODIFY),
-			GetDlgItem(IDC_BUTTON_DELETE),
-			GetDlgItem(IDC_BUTTON_DELETE_ALL),
-			GetDlgItem(IDC_BUTTON_REFRESH)
-		};
-
-		int y = margin;
-		for (auto pBtn : buttons) {
-			if (pBtn && pBtn->GetSafeHwnd()) {
-				pBtn->MoveWindow(rect.right - buttonWidth - margin, y, buttonWidth, buttonHeight);
-				y += buttonHeight + buttonSpacing;
-			}
-		}
-
-		// 鍒楀閲嶈
-		int col0 = 50;  // No.
-		int col1 = 120; // PPID
-		int col3 = 160; // 鍒涘缓鏃堕棿鑷姩濉厖
-		int col2 = listWidth - col0 - col1 - col3 - 2;  // 鎻忚堪鑷姩濉厖
-		if (col2 < 80) { 
-			col2 = 80;
-		}
-
-		m_listPPID.SetColumnWidth(1, col0);
-		m_listPPID.SetColumnWidth(2, col1);
-		m_listPPID.SetColumnWidth(3, col2);
-		m_listPPID.SetColumnWidth(4, col3);
 	}
 }
 
 void CPageRecipe::OnBnClickedButtonSearch()
 {
-	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
-	CString strInput;
-	m_editPPID.GetWindowText(strInput);
-
-	int nCount = m_listPPID.GetItemCount();
-	for (int i = 0; i < nCount; ++i) {
-		CString strItemText = m_listPPID.GetItemText(i, 2); // 绗�2鍒椾负PPID
-		if (strItemText == strInput) {
-			m_listPPID.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
-			m_listPPID.EnsureVisible(i, FALSE);
-			break;
-		}
-	}
+	CString strKeyword;
+	GetDlgItemText(IDC_EDIT_KEYWORD, strKeyword);
+	AfxMessageBox(strKeyword);
 }
 
 void CPageRecipe::OnBnClickedButtonModify()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	/*
 	POSITION pos = m_listPPID.GetFirstSelectedItemPosition();
 	if (!pos) {
 		AfxMessageBox(_T("璇烽�夋嫨瑕佷慨鏀圭殑閰嶆柟"));
@@ -238,6 +220,7 @@
 			AfxMessageBox(_T("鎻忚堪鏇存柊澶辫触"));
 		}
 	}
+	*/
 }
 
 void CPageRecipe::OnBnClickedButtonDelete()
@@ -299,14 +282,25 @@
 	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
 	*pResult = 0;
 
-	if ((pNMLV->uChanged & LVIF_STATE) &&
-		(pNMLV->uNewState & LVIS_SELECTED)) {
+	int selectedCount = ListView_GetSelectedCount(m_listPPID.GetSafeHwnd());
+	GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(selectedCount > 0);
+}
 
-		int nItem = pNMLV->iItem;
-		CString strPPID = m_listPPID.GetItemText(nItem, 2);
-		m_editPPID.SetWindowText(strPPID);
+void CPageRecipe::OnDestroy()
+{
+	CDialogEx::OnDestroy();
 
-		CString strDesc = m_listPPID.GetItemText(nItem, 3);
-		m_editDesc.SetWindowText(strDesc);
+	// 淇濆瓨鍒楀
+	CString strIniFile, strItem, strTemp;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	CHeaderCtrl* pHeader = m_listPPID.GetHeaderCtrl();
+	for (int i = 0; i < pHeader->GetItemCount(); i++) {
+		RECT rect;
+		pHeader->GetItemRect(i, &rect);
+		strItem.Format(_T("Col_%d_Width"), i);
+		strTemp.Format(_T("%d"), rect.right - rect.left);
+		WritePrivateProfileString("PageRecipeListCtrl", strItem, strTemp, strIniFile);
 	}
-}
\ No newline at end of file
+}
diff --git a/SourceCode/Bond/Servo/PageRecipe.h b/SourceCode/Bond/Servo/PageRecipe.h
index 5df946e..32bf429 100644
--- a/SourceCode/Bond/Servo/PageRecipe.h
+++ b/SourceCode/Bond/Servo/PageRecipe.h
@@ -34,6 +34,6 @@
 
 private:
 	CListCtrl m_listPPID;
-	CEdit m_editPPID;
-	CEdit m_editDesc;
+public:
+	afx_msg void OnDestroy();
 };
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index e154e98..65bfe05 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index e5eb250..4c0cf0a 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3