From 4d9d8d22e3666076988c30afb4e7c6fe365c19aa Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期二, 06 一月 2026 18:53:04 +0800
Subject: [PATCH] 1.修复一个回复错误的问题;

---
 SourceCode/Bond/Servo/PageAlarm.cpp |   78 ++++++++++++++++++++++++++++++++++----
 1 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageAlarm.cpp b/SourceCode/Bond/Servo/PageAlarm.cpp
index 51c0f1a..dd6a8e4 100644
--- a/SourceCode/Bond/Servo/PageAlarm.cpp
+++ b/SourceCode/Bond/Servo/PageAlarm.cpp
@@ -39,9 +39,16 @@
 
 CPageAlarm::~CPageAlarm()
 {
+	if (m_hbrBkgnd != nullptr) {
+		::DeleteObject(m_hbrBkgnd);
+	}
+	if (m_pObserver != nullptr) {
+		m_pObserver->unsubscribe();
+		m_pObserver = nullptr;
+	}
 }
 
-void CPageAlarm::InitRxWindow()
+void CPageAlarm::InitRxWindows()
 {
 	/* code */
 	// 璁㈤槄鏁版嵁
@@ -75,12 +82,52 @@
 
 void CPageAlarm::Resize()
 {
-	CWnd* pItem;
 	CRect rcClient;
 	GetClientRect(&rcClient);
 
-	pItem = GetDlgItem(IDC_LIST_ALARM);
-	pItem->MoveWindow(12, 58, rcClient.Width() - 24, rcClient.Height() - 64);
+	// ===== 甯搁噺瀹氫箟 =====
+	const int nLeft = 12;
+	const int nRight = 12;
+	const int nTop = 58;
+	const int nButtonHeight = 28;
+	const int nButtonMarginBottom = 12;
+	const int nSpacing = 8;
+	const int nButtonWidth = 80;
+	const int nLabelWidth = 100;
+
+	// ===== 鍒嗛〉鎺т欢甯冨眬 =====
+	int yBottom = rcClient.bottom - nButtonMarginBottom - nButtonHeight;
+	int xRight = rcClient.Width() - nRight;
+
+	CWnd* pBtnNext = GetDlgItem(IDC_BUTTON_NEXT_PAGE);
+	CWnd* pBtnPrev = GetDlgItem(IDC_BUTTON_PREV_PAGE);
+	CWnd* pLabelPage = GetDlgItem(IDC_LABEL_PAGE_NUMBER);
+
+	if (pBtnNext && pBtnPrev && pLabelPage) {
+		// 鑾峰彇鍒嗛〉鏂囨湰瀹藉害浼扮畻
+		//CString strLabel;
+		//GetDlgItemText(IDC_LABEL_PAGE_NUMBER, strLabel);
+		//if (strLabel.IsEmpty()) {
+		//	strLabel = _T("绗� 1 / 1 椤�");
+		//}
+		//int nCharWidth = 8;
+		//int nLabelWidth = strLabel.GetLength() * nCharWidth + 20;
+
+		// 璁剧疆鎸夐挳鍜屾爣绛句綅缃�
+		pBtnNext->MoveWindow(xRight - nButtonWidth, yBottom, nButtonWidth, nButtonHeight);
+		xRight -= nButtonWidth + nSpacing;
+
+		pLabelPage->MoveWindow(xRight - nLabelWidth, yBottom, nLabelWidth, nButtonHeight);
+		xRight -= nLabelWidth + nSpacing;
+
+		pBtnPrev->MoveWindow(xRight - nButtonWidth, yBottom, nButtonWidth, nButtonHeight);
+	}
+
+	// ===== 琛ㄦ牸鍖哄煙甯冨眬 =====
+	if (nullptr != m_listCtrl.m_hWnd) {
+		int listHeight = yBottom - nTop - nSpacing;
+		m_listCtrl.MoveWindow(nLeft, nTop, rcClient.Width() - nLeft - nRight, listHeight);
+	}
 }
 
 void CPageAlarm::LoadAlarms()
@@ -93,7 +140,7 @@
 void CPageAlarm::UpdatePageData()
 {
 	// 鏍规嵁杩囨护鏉′欢鍔犺浇鏁版嵁锛屾彁渚涙弿杩板拰鏃堕棿鑼冨洿鏌ヨ
-	auto vecData = AlarmManager::getInstance().getFilteredAlarms("", "", m_strDeviceName, m_strUnitName, m_strKeyword, m_szTimeStart, m_szTimeEnd, m_nCurPage, PAGE_SIZE);
+	auto vecData = AlarmManager::getInstance().getFilteredAlarms(m_strKeyword, m_szTimeStart, m_szTimeEnd, m_nCurPage, PAGE_SIZE);
 
 	// 濉厖鏁版嵁鍒版帶浠�
 	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
@@ -107,12 +154,15 @@
 {
 	// 鏇存柊鍒嗛〉淇℃伅
 	CString strPage;
-	strPage.Format(_T("绗� %d 椤�"), m_nCurPage);
+	strPage.Format(_T("绗� %d / %d 椤�"), m_nCurPage, m_nTotalPages);
 	SetDlgItemText(IDC_LABEL_PAGE_NUMBER, strPage);
 
 	// 鍚敤/绂佺敤缈婚〉鎸夐挳
 	GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurPage > 1);
 	GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurPage < m_nTotalPages);
+
+	// 璋冩暣鎺т欢澶у皬
+	// Resize();
 }
 
 void CPageAlarm::FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<AlarmData>& vecData)
@@ -146,7 +196,7 @@
 		pListCtrl->DeleteItem(nRowCount - 1);
 	}
 
-	int nNewItem = pListCtrl->InsertItem(0, _T(""));
+	int nNewItem = pListCtrl->InsertItem(pListCtrl->GetItemCount(), _T(""));
 
 	// 璁剧疆姣忎竴鍒楃殑鏁版嵁
 	CString str;
@@ -199,6 +249,7 @@
 BOOL CPageAlarm::OnInitDialog()
 {
 	CDialogEx::OnInitDialog();
+	InitRxWindows();
 	SetTimer(1, 3000, nullptr);
 
 	// 涓嬫媺妗嗘帶浠�
@@ -247,7 +298,7 @@
 
 
 	// 璁$畻鎬婚〉鏁�
-	int totalRecords = AlarmManager::getInstance().getTotalAlarmCount("", "", m_strDeviceName, m_strUnitName, m_strKeyword, m_szTimeStart, m_szTimeEnd);
+	int totalRecords = AlarmManager::getInstance().getTotalAlarmCount(m_strKeyword, m_szTimeStart, m_szTimeEnd);
 	m_nTotalPages = (totalRecords + PAGE_SIZE - 1) / PAGE_SIZE;
 	m_nCurPage = 1;
 
@@ -376,7 +427,7 @@
 	}
 
 	// 璁$畻鎬婚〉鏁�
-	int totalRecords = AlarmManager::getInstance().getTotalAlarmCount("", "", m_strDeviceName, m_strUnitName, m_strKeyword, m_szTimeStart, m_szTimeEnd);
+	int totalRecords = AlarmManager::getInstance().getTotalAlarmCount(m_strKeyword, m_szTimeStart, m_szTimeEnd);
 	m_nTotalPages = (totalRecords + PAGE_SIZE - 1) / PAGE_SIZE;
 	m_nCurPage = 1;
 
@@ -456,3 +507,12 @@
 	m_nCurPage++;
 	UpdatePageData();  // 璋冪敤鍒嗛〉鏇存柊鍑芥暟
 }
+
+BOOL CPageAlarm::PreTranslateMessage(MSG* pMsg)
+{
+	if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) {
+		return TRUE;
+	}
+
+	return CDialogEx::PreTranslateMessage(pMsg);
+}

--
Gitblit v1.9.3