From 50a42e5d72e2f8cf92ff9b2273e0442977dbcefd Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期三, 18 十二月 2024 18:28:02 +0800
Subject: [PATCH] 1. 对话框基类添加动态控件管理 2. 对话框基类主题切换功能

---
 SourceCode/Bond/BondEq/CBaseDlg.h |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/SourceCode/Bond/BondEq/CBaseDlg.h b/SourceCode/Bond/BondEq/CBaseDlg.h
index 053cd99..f817e60 100644
--- a/SourceCode/Bond/BondEq/CBaseDlg.h
+++ b/SourceCode/Bond/BondEq/CBaseDlg.h
@@ -1,4 +1,18 @@
 #pragma once
+#include <memory>
+#include <unordered_map>
+
+enum class ThemeType {
+	Light,  // 浅色主题
+	Dark    // 深色主题
+};
+
+struct Theme {
+	COLORREF backgroundColor;
+	COLORREF textColor;
+	COLORREF buttonColor;
+	COLORREF borderColor;
+};
 
 class CBaseDlg : public CDialogEx
 {
@@ -8,22 +22,35 @@
 	CBaseDlg(UINT id, CWnd* pPage);				// 标准构造函数
 	virtual ~CBaseDlg();						// 析构函数
 
+	// 字体管理
 	CFont* GetOrCreateFont(int nFontSize);		// 获取或创建字体
 	void SetDefaultFont();						// 设置默认字体
+
+	// 动态控件管理
+	BOOL AddControl(UINT nCtrlID, CWnd* pControl);					// 添加控件
+	BOOL RemoveControl(UINT nCtrlID);								// 移除控件
+	BOOL UpdateControlText(UINT nCtrlID, const CString& strText);   // 更新控件文本
+	CWnd* GetControl(UINT nCtrlID);									// 获取控件
+
+	// 主题设置
+	void SwitchTheme(ThemeType themeType);							// 切换主题
 
 private:
 	void AdjustControls(float dScaleX, float dScaleY);				// 调整控件大小
 	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);	// 调整控件字体
 
 private:
-	int m_nInitialWidth;						// 对话框初始宽度
-	int m_nInitialHeight;						// 对话框初始高度	
-	std::map<int, CFont*> m_mapFonts;			// 控件字体
-	std::map<int, CRect> m_mapCtrlLayouts;		// 控件布局
+	bool m_bResizing;											// 控件是否正在调整大小
+	int m_nInitialWidth;										// 对话框初始宽度
+	int m_nInitialHeight;										// 对话框初始高度	
+	std::unordered_map<int, CRect> m_mapCtrlLayouts;			// 控件布局
+	std::map<UINT, std::unique_ptr<CWnd>> m_mapControls;		// 控件集合
+	std::unordered_map<int, std::shared_ptr<CFont>> m_mapFonts;	// 控件字体
 
 	DECLARE_MESSAGE_MAP()
 public:
 	virtual BOOL OnInitDialog();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 };
\ No newline at end of file

--
Gitblit v1.9.3