| | |
| | | #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 |
| | | { |
| | |
| | | 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); |
| | | }; |