From 89bcc7791c48d8bcf8e124e56849e44563f8097c Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期一, 23 十二月 2024 18:34:18 +0800
Subject: [PATCH] 1.对话框基类加载资源库、卸载资源库 2. 报警模块的界面添加分页功能

---
 SourceCode/Bond/BondEq/CBaseDlg.cpp |   86 ++++++++++++++++++++++++++++--------------
 1 files changed, 57 insertions(+), 29 deletions(-)

diff --git a/SourceCode/Bond/BondEq/CBaseDlg.cpp b/SourceCode/Bond/BondEq/CBaseDlg.cpp
index 2ddd896..86b7926 100644
--- a/SourceCode/Bond/BondEq/CBaseDlg.cpp
+++ b/SourceCode/Bond/BondEq/CBaseDlg.cpp
@@ -9,10 +9,15 @@
 CFont g_defaultFont;
 Theme* g_currentTheme = &g_lightTheme;
 
+// 全局资源句柄
+HINSTANCE g_hCurrentResource = NULL;
+
 IMPLEMENT_DYNAMIC(CBaseDlg, CDialogEx)
 
-CBaseDlg::CBaseDlg(UINT id, CWnd* pPage) : CDialogEx(id, pPage), m_bResizing(false)
+CBaseDlg::CBaseDlg(UINT nID, CWnd* pPage) : CDialogEx(nID, pPage), m_bResizing(false)
 {
+	m_nID = nID;
+	m_pParent = pPage;
 	m_nInitialWidth = 0;
 	m_nInitialHeight = 0;
 }
@@ -23,6 +28,57 @@
 	m_mapFonts.clear();
 	m_mapCtrlLayouts.clear();
 	m_mapControls.clear();
+}
+
+void CBaseDlg::SwitchTheme(ThemeType enThemeType)
+{
+	// 使用 map 来根据 themeType 查找主题
+	static const std::unordered_map<ThemeType, Theme*> themeMap = {
+		{ ThemeType::Light, &g_lightTheme },
+		{ ThemeType::Dark, &g_darkTheme }
+	};
+
+	// 设置当前主题
+	auto it = themeMap.find(enThemeType);
+	if (it != themeMap.end()) {
+		g_currentTheme = it->second;
+	}
+	else {
+		g_currentTheme = &g_lightTheme;
+	}
+
+	// 更新控件的外观
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		pWnd->Invalidate();
+		pWnd = pWnd->GetNextWindow();
+	}
+
+	// 更新对话框背景颜色
+	SetBackgroundColor(g_currentTheme->backgroundColor);
+}
+
+void CBaseDlg::LoadResourceLibrary(const CString& strLanguage)
+{
+	// 卸载之前加载的资源库
+	UnloadResourceLibrary();
+
+	// 加载新的资源库
+	g_hCurrentResource = AfxLoadLibrary(strLanguage);
+
+	// 设置新的资源句柄
+	if (g_hCurrentResource != NULL) {
+		AfxSetResourceHandle(g_hCurrentResource);
+	}
+}
+
+void CBaseDlg::UnloadResourceLibrary()
+{
+	// 卸载之前加载的资源库
+	if (g_hCurrentResource != NULL) {
+		FreeLibrary(g_hCurrentResource);	// 释放当前资源库
+		g_hCurrentResource = NULL;			// 清空资源句柄
+	}
 }
 
 CFont* CBaseDlg::GetOrCreateFont(int nFontSize)
@@ -104,34 +160,6 @@
 		return it->second.get();
 	}
 	return nullptr;
-}
-
-void CBaseDlg::SwitchTheme(ThemeType themeType)
-{
-	// 使用 map 来根据 themeType 查找主题
-	static const std::unordered_map<ThemeType, Theme*> themeMap = {
-		{ ThemeType::Light, &g_lightTheme },
-		{ ThemeType::Dark, &g_darkTheme }
-	};
-
-	// 设置当前主题
-	auto it = themeMap.find(themeType);
-	if (it != themeMap.end()) {
-		g_currentTheme = it->second;
-	}
-	else {
-		g_currentTheme = &g_lightTheme;
-	}
-
-	// 更新控件的外观
-	CWnd* pWnd = GetWindow(GW_CHILD);
-	while (pWnd) {
-		pWnd->Invalidate(); // 重绘控件
-		pWnd = pWnd->GetNextWindow();
-	}
-
-	// 更新对话框背景颜色
-	SetBackgroundColor(g_currentTheme->backgroundColor);
 }
 
 void CBaseDlg::AdjustControls(float dScaleX, float dScaleY)

--
Gitblit v1.9.3