From d84ddeea533a8e5f122cc4a2fed06e93c2aacf3d Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期四, 21 十一月 2024 18:30:02 +0800
Subject: [PATCH] 1.显示对话框继续缩放 2.登录界面加载图片

---
 SourceCode/Bond/BondEq/View/LoginDlg.h              |   12 
 SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp |  172 +++++++++++-------
 SourceCode/Bond/BondEq/Resource.h                   |    0 
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.h       |    6 
 SourceCode/Bond/BondEq/View/UserManagerDlg.h        |    5 
 SourceCode/Bond/BondEq/BondEq.rc                    |    0 
 SourceCode/Bond/BondEq/View/UserManagerDlg.cpp      |  150 +++++++++++-----
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp     |  119 ++++++------
 SourceCode/Bond/BondEq/View/LoginDlg.cpp            |   38 ++-
 SourceCode/Bond/BondEq/BondEq.vcxproj               |    4 
 SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h   |    7 
 11 files changed, 304 insertions(+), 209 deletions(-)

diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index 727ece9..d6fab05 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj b/SourceCode/Bond/BondEq/BondEq.vcxproj
index 926d220..8c008d2 100644
--- a/SourceCode/Bond/BondEq/BondEq.vcxproj
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -196,7 +196,6 @@
     <ClInclude Include="Alarm.h" />
     <ClInclude Include="AlarmMonitor.h" />
     <ClInclude Include="ApredTreeCtrl.h" />
-    <ClInclude Include="AxisSettingsDlg.h" />
     <ClInclude Include="BaseSetPage.h" />
     <ClInclude Include="BlButton.h" />
     <ClInclude Include="BondEq.h" />
@@ -245,6 +244,7 @@
     <ClInclude Include="ToolUnits.h" />
     <ClInclude Include="TopToolbar.h" />
     <ClInclude Include="VerticalLine.h" />
+    <ClInclude Include="View\AxisSettingsDlg.h" />
     <ClInclude Include="View\ChangePasswordDlg.h" />
     <ClInclude Include="View\LoginDlg.h" />
     <ClInclude Include="View\SystemLogManagerDlg.h" />
@@ -256,7 +256,6 @@
     <ClCompile Include="Alarm.cpp" />
     <ClCompile Include="AlarmMonitor.cpp" />
     <ClCompile Include="ApredTreeCtrl.cpp" />
-    <ClCompile Include="AxisSettingsDlg.cpp" />
     <ClCompile Include="BaseSetPage.cpp" />
     <ClCompile Include="BlButton.cpp" />
     <ClCompile Include="BondEq.cpp" />
@@ -307,6 +306,7 @@
     <ClCompile Include="ToolUnits.cpp" />
     <ClCompile Include="TopToolbar.cpp" />
     <ClCompile Include="VerticalLine.cpp" />
+    <ClCompile Include="View\AxisSettingsDlg.cpp" />
     <ClCompile Include="View\ChangePasswordDlg.cpp" />
     <ClCompile Include="View\LoginDlg.cpp" />
     <ClCompile Include="View\SystemLogManagerDlg.cpp" />
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 7394cbf..2dca32a 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ
diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
similarity index 76%
rename from SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
rename to SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index 867e469..d12c269 100644
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -34,25 +34,27 @@
 	CDialogEx::DoDataExchange(pDX);
 }
 
+CFont* CAxisSettingsDlg::GetOrCreateFont(int nFontSize)
+{
+	auto it = m_mapFonts.find(nFontSize);
+	if (it != m_mapFonts.end()) {
+		return it->second;
+	}
+
+	CFont* font = new CFont();
+	LOGFONT logFont = { 0 };
+	_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
+	logFont.lfHeight = -nFontSize;
+	logFont.lfQuality = CLEARTYPE_QUALITY;
+	font->CreateFontIndirect(&logFont);
+	m_mapFonts[nFontSize] = font;
+
+	return font;
+}
+
 void CAxisSettingsDlg::SetDefaultFont()
 {
-	CFont* defaultFont = nullptr;
-
-	// 濡傛灉瀛椾綋绠$悊瀹瑰櫒涓湁榛樿澶у皬锛堝 12锛夌殑瀛椾綋锛岀洿鎺ヤ娇鐢�
-	auto it = m_mapFonts.find(12);
-	if (it != m_mapFonts.end()) {
-		defaultFont = it->second;
-	}
-	else {
-		// 鍒涘缓榛樿瀛椾綋
-		defaultFont = new CFont();
-		LOGFONT logFont = { 0 };
-		_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
-		logFont.lfHeight = -12;
-		logFont.lfQuality = CLEARTYPE_QUALITY;
-		defaultFont->CreateFontIndirect(&logFont);
-		m_mapFonts[12] = defaultFont; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
-	}
+	CFont* defaultFont = GetOrCreateFont(12);
 
 	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
 	CWnd* pWnd = GetWindow(GW_CHILD);
@@ -62,34 +64,31 @@
 	}
 }
 
-void CAxisSettingsDlg::AdjustControls(int nWidth, int nHeight)
+void CAxisSettingsDlg::AdjustControls(float dScaleX, float dScaleY)
 {
 	CWnd* pWnd = GetWindow(GW_CHILD);
 	while (pWnd) {
-		UINT nCtrlID = pWnd->GetDlgCtrlID();
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1 && m_mapCtrlLayouts.find(nCtrlID) != m_mapCtrlLayouts.end())
+		{
+			CRect originalRect = m_mapCtrlLayouts[nCtrlID];
+			CRect newRect(
+				static_cast<int>(originalRect.left * dScaleX),
+				static_cast<int>(originalRect.top * dScaleY),
+				static_cast<int>(originalRect.right * dScaleX),
+				static_cast<int>(originalRect.bottom * dScaleY));
 
-		CRect ctrlRect;
-		pWnd->GetWindowRect(&ctrlRect);
-		ScreenToClient(&ctrlRect);
+			TCHAR szClassName[256];
+			GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
 
-		// 璁$畻鎺т欢鐨勬柊浣嶇疆鍜屽ぇ灏忥紝鎸夋瘮渚嬭皟鏁�
-		int newX = (int)(ctrlRect.left * (nWidth / (float)m_nInitialWidth));
-		int newY = (int)(ctrlRect.top * (nHeight / (float)m_nInitialHeight));
-		int newWidth = (int)(ctrlRect.Width() * (nWidth / (float)m_nInitialWidth));
-		int newHeight = (int)(ctrlRect.Height() * (nHeight / (float)m_nInitialHeight));
+			if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
+				CComboBox* pComboBox = (CComboBox*)pWnd;
+				pComboBox->SetItemHeight(-1, newRect.Height());  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			}
 
-		TCHAR szClassName[256];
-		GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-
-		if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
-			CComboBox* pComboBox = (CComboBox*)pWnd;
-			pComboBox->SetItemHeight(-1, nHeight);  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			pWnd->MoveWindow(&newRect);
+			AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
 		}
-
-		pWnd->MoveWindow(newX, newY, newWidth, newHeight);
-		AdjustControlFont(pWnd, newWidth, newHeight);
-
-		// 鑾峰彇涓嬩竴涓帶浠�
 		pWnd = pWnd->GetNextWindow();
 	}
 }
@@ -100,23 +99,10 @@
 	int fontSize = nHeight / 2;
 	if (fontSize < 8) fontSize = 8;
 
-	// 妫�鏌ュ瓧浣撴槸鍚﹀凡缁忓瓨鍦�
-	auto it = m_mapFonts.find(fontSize);
-	if (it == m_mapFonts.end()) {
-		// 鍔ㄦ�佸垱寤烘柊瀛椾綋
-		CFont* newFont = new CFont();
-		LOGFONT logFont = { 0 };
-		_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
-		logFont.lfHeight = -fontSize;
-		logFont.lfQuality = CLEARTYPE_QUALITY; // 鍚敤 ClearType 鎶楅敮榻�
-		newFont->CreateFontIndirect(&logFont);
+	// 鑾峰彇鎴栧垱寤哄瓧浣�
+	CFont* pFont = GetOrCreateFont(fontSize);
 
-		// 瀛樺偍鍒板瓧浣撶鐞嗗鍣ㄤ腑
-		m_mapFonts[fontSize] = newFont;
-		it = m_mapFonts.find(fontSize);
-	}
-
-	pWnd->SetFont(it->second);
+	pWnd->SetFont(pFont);
 	pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
 }
 
@@ -152,16 +138,31 @@
 	CDialogEx::OnInitDialog();
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
-	//ModifyStyle(0, WS_THICKFRAME | WS_SIZEBOX);
-
-	// 璁剧疆榛樿瀛椾綋
-	SetDefaultFont();
-
 	CRect screenRect, dlgRect, clientRect;
 	GetClientRect(&clientRect);
 	m_nInitialWidth = clientRect.Width();
 	m_nInitialHeight = clientRect.Height();
 
+	// 鍒濆鍖栭粯璁ゅ瓧浣�
+	CFont* pDefaultFont = GetOrCreateFont(12);
+
+	// 閬嶅巻鎵�鏈夊瓙鎺т欢锛岃褰曞垵濮嬩綅缃苟璁剧疆榛樿瀛椾綋
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1) {
+			// 璁板綍鎺т欢鍒濆甯冨眬
+			CRect ctrlRect;
+			pWnd->GetWindowRect(&ctrlRect);
+			ScreenToClient(&ctrlRect);
+			m_mapCtrlLayouts[nCtrlID] = ctrlRect;
+
+			// 璁剧疆榛樿瀛椾綋
+			pWnd->SetFont(pDefaultFont);
+		}
+		pWnd = pWnd->GetNextWindow();
+	}
+
 	GetWindowRect(&dlgRect);
 	int dlgWidth = dlgRect.Width() * 2;
 	int dlgHeight = dlgRect.Height() * 2;
diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
similarity index 90%
rename from SourceCode/Bond/BondEq/AxisSettingsDlg.h
rename to SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
index 5072027..6c73683 100644
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
@@ -18,14 +18,16 @@
 #endif
 
 private:
+	CFont* GetOrCreateFont(int nFontSize);
 	void SetDefaultFont();
-	void AdjustControls(int nWidth, int nHeight);
+	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;
+	std::map<int, CFont*> m_mapFonts;
 
 protected:
 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
diff --git a/SourceCode/Bond/BondEq/View/LoginDlg.cpp b/SourceCode/Bond/BondEq/View/LoginDlg.cpp
index b78c28d..edacdb8 100644
--- a/SourceCode/Bond/BondEq/View/LoginDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/LoginDlg.cpp
@@ -23,11 +23,11 @@
 
 void CLoginDlg::DoDataExchange(CDataExchange* pDX)
 {
-	CDialogEx::DoDataExchange(pDX);
-	DDX_Control(pDX, IDC_EDIT_USERNAME, m_editUsername);
-	DDX_Control(pDX, IDC_EDIT_PASSWORD, m_editPassword);
-	DDX_Control(pDX, IDC_COMBO_ROLE, m_comboRole);
-	DDX_Control(pDX, IDC_CHECK_REMEMBER_PASSWORD, m_checkRememberPassword);
+    CDialogEx::DoDataExchange(pDX);
+    DDX_Control(pDX, IDC_STATIC_IMAGE, m_staticImage);
+    DDX_Control(pDX, IDC_EDIT_USERNAME, m_editUsername);
+    DDX_Control(pDX, IDC_EDIT_PASSWORD, m_editPassword);
+    DDX_Control(pDX, IDC_CHECK_REMEMBER_PASSWORD, m_checkRememberPassword);
 }
 
 
@@ -46,10 +46,24 @@
 
     // 璁剧疆绐楀彛鏍囬鍜屽垵濮嬪��
     SetWindowText(_T("鐧诲綍"));
-	m_comboRole.AddString(_T("绠$悊鍛�"));
-	m_comboRole.AddString(_T("宸ョ▼甯�"));
-    m_comboRole.AddString(_T("鎿嶄綔鍛�"));
-    m_comboRole.SetCurSel(0);
+
+    CString strIconPath;
+    strIconPath.Format(_T("%s\\Res\\Operator_High_32.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+
+    // 鍔犺浇鍥炬爣
+    HICON hIcon = (HICON)::LoadImage(
+        nullptr,
+        strIconPath,
+        IMAGE_ICON,
+        32, // 鍥炬爣瀹藉害
+        32, // 鍥炬爣楂樺害
+        LR_LOADFROMFILE);
+
+    if (hIcon) {
+        // 璁剧疆 CStatic 鎺т欢涓哄浘鏍囨牱寮�
+        m_staticImage.ModifyStyle(0xF, SS_ICON);
+        m_staticImage.SetIcon(hIcon);
+    }
 
     // 娣诲姞SS_NOTIFY鏍峰紡
     CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_CHANGE_PASSWORD);
@@ -59,11 +73,6 @@
 
     UserManager& userManager = UserManager::getInstance();
 	if (userManager.isLoggedIn()) {
-		int nRole = (int)userManager.getCurrentUserRole();
-        if (nRole <= m_comboRole.GetCount()) {
-            m_comboRole.SetCurSel(nRole);
-        }
-
         if (userManager.isRememberMe()) {
             m_checkRememberPassword.SetCheck(BST_CHECKED);
         }
@@ -81,7 +90,6 @@
     CString username, password, role;
     m_editUsername.GetWindowText(username);
     m_editPassword.GetWindowText(password);
-    m_comboRole.GetLBText(m_comboRole.GetCurSel(), role);
 
     if (username.IsEmpty() || password.IsEmpty()) {
         AfxMessageBox(_T("璇疯緭鍏ョ敤鎴峰悕鍜屽瘑鐮併��"));
diff --git a/SourceCode/Bond/BondEq/View/LoginDlg.h b/SourceCode/Bond/BondEq/View/LoginDlg.h
index e4674d5..b2d2a1a 100644
--- a/SourceCode/Bond/BondEq/View/LoginDlg.h
+++ b/SourceCode/Bond/BondEq/View/LoginDlg.h
@@ -17,16 +17,16 @@
 	enum { IDD = IDD_DIALOG_LOGIN };
 #endif
 
+private:
+	CStatic m_staticImage;
+	CEdit m_editUsername;
+	CEdit m_editPassword;
+	CButton m_checkRememberPassword;
+
 protected:
 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
 	virtual BOOL OnInitDialog();
 	afx_msg void OnBnClickedLogin();
 	afx_msg void OnBnClickedChangePassword();
 	DECLARE_MESSAGE_MAP()
-
-private:
-	CEdit m_editUsername;
-	CEdit m_editPassword;
-	CComboBox m_comboRole;
-	CButton m_checkRememberPassword;
 };
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
index 004e2d8..f5603fb 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
@@ -14,7 +14,8 @@
 CSystemLogManagerDlg::CSystemLogManagerDlg(CWnd* pParent /*=nullptr*/)
 	: CDialogEx(IDD_DIALOG_SYSTEM_LOG_MANAGER, pParent)
 {
-
+	m_nInitialWidth = 0;
+	m_nInitialHeight = 0;
 }
 
 CSystemLogManagerDlg::~CSystemLogManagerDlg()
@@ -70,11 +71,11 @@
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("No."));
 	m_listLogs.SetColumnWidth(nColIdx, 10);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("绫诲瀷"));
-	m_listLogs.SetColumnWidth(nColIdx, 200);
+	m_listLogs.SetColumnWidth(nColIdx, 100);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("浜嬩欢"));
 	m_listLogs.SetColumnWidth(nColIdx, 30);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("鐢ㄦ埛"));
-	m_listLogs.SetColumnWidth(nColIdx, 70);
+	m_listLogs.SetColumnWidth(nColIdx, 50);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("鏃堕棿"));
 
 	// 鍒涘缓 20 琛岀┖鐧芥暟鎹
@@ -152,11 +153,30 @@
 		}
 	}
 
-	m_listLogs.Invalidate();
-	m_listLogs.UpdateWindow();
 	m_listLogs.ExpandColumnsToFit(FALSE);
 	m_listLogs.ExpandLastColumn();
+	m_listLogs.Invalidate();
+	m_listLogs.UpdateWindow();
+
 	UpdatePageInfo();
+}
+
+CFont* CSystemLogManagerDlg::GetOrCreateFont(int nFontSize)
+{
+	auto it = m_mapFonts.find(nFontSize);
+	if (it != m_mapFonts.end()) {
+		return it->second;
+	}
+
+	CFont* font = new CFont();
+	LOGFONT logFont = { 0 };
+	_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
+	logFont.lfHeight = -nFontSize;
+	logFont.lfQuality = CLEARTYPE_QUALITY;
+	font->CreateFontIndirect(&logFont);
+	m_mapFonts[nFontSize] = font;
+
+	return font;
 }
 
 void CSystemLogManagerDlg::UpdatePageInfo()
@@ -169,23 +189,7 @@
 
 void CSystemLogManagerDlg::SetDefaultFont()
 {
-	CFont* defaultFont = nullptr;
-
-	// 濡傛灉瀛椾綋绠$悊瀹瑰櫒涓湁榛樿澶у皬锛堝 12锛夌殑瀛椾綋锛岀洿鎺ヤ娇鐢�
-	auto it = m_mapFonts.find(12);
-	if (it != m_mapFonts.end()) {
-		defaultFont = it->second;
-	}
-	else {
-		// 鍒涘缓榛樿瀛椾綋
-		defaultFont = new CFont();
-		LOGFONT logFont = { 0 };
-		_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
-		logFont.lfHeight = -12;
-		logFont.lfQuality = CLEARTYPE_QUALITY;
-		defaultFont->CreateFontIndirect(&logFont);
-		m_mapFonts[12] = defaultFont; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
-	}
+	CFont* defaultFont = GetOrCreateFont(12);
 
 	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
 	CWnd* pWnd = GetWindow(GW_CHILD);
@@ -203,41 +207,40 @@
 	}
 }
 
-void CSystemLogManagerDlg::AdjustControls(int nWidth, int nHeight)
+void CSystemLogManagerDlg::AdjustControls(float dScaleX, float dScaleY)
 {
 	CWnd* pWnd = GetWindow(GW_CHILD);
 	while (pWnd) {
-		UINT nCtrlID = pWnd->GetDlgCtrlID();
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1 && m_mapCtrlLayouts.find(nCtrlID) != m_mapCtrlLayouts.end())
+		{
+			CRect originalRect = m_mapCtrlLayouts[nCtrlID];
+			CRect newRect(
+				static_cast<int>(originalRect.left * dScaleX),
+				static_cast<int>(originalRect.top * dScaleY),
+				static_cast<int>(originalRect.right * dScaleX),
+				static_cast<int>(originalRect.bottom * dScaleY));
 
-		CRect ctrlRect;
-		pWnd->GetWindowRect(&ctrlRect);
-		ScreenToClient(&ctrlRect);
+			TCHAR szClassName[256];
+			GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
 
-		// 璁$畻鎺т欢鐨勬柊浣嶇疆鍜屽ぇ灏忥紝鎸夋瘮渚嬭皟鏁�
-		int newX = (int)(ctrlRect.left * (nWidth / (float)m_nInitialWidth));
-		int newY = (int)(ctrlRect.top * (nHeight / (float)m_nInitialHeight));
-		int newWidth = (int)(ctrlRect.Width() * (nWidth / (float)m_nInitialWidth));
-		int newHeight = (int)(ctrlRect.Height() * (nHeight / (float)m_nInitialHeight));
+			if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
+				CComboBox* pComboBox = (CComboBox*)pWnd;
+				pComboBox->SetItemHeight(-1, newRect.Height());  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			}
 
-		TCHAR szClassName[256];
-		GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+			if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+				CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
+				pGridCtrl->SetDefCellHeight(newRect.Height() / 21);
+				pGridCtrl->ExpandColumnsToFit(TRUE);
+				pGridCtrl->ExpandLastColumn();
+				pGridCtrl->Invalidate();
+				pGridCtrl->UpdateWindow();
+			}
 
-		if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
-			CComboBox* pComboBox = (CComboBox*)pWnd;
-			pComboBox->SetItemHeight(-1, nHeight);  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			pWnd->MoveWindow(&newRect);
+			AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
 		}
-
-		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
-			CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
-			pGridCtrl->SetDefCellHeight(newHeight / 21);
-			pGridCtrl->ExpandColumnsToFit(TRUE);
-			pGridCtrl->Invalidate();
-		}
-
-		pWnd->MoveWindow(newX, newY, newWidth, newHeight);
-		AdjustControlFont(pWnd, newWidth, newHeight);
-
-		// 鑾峰彇涓嬩竴涓帶浠�
 		pWnd = pWnd->GetNextWindow();
 	}
 }
@@ -256,23 +259,10 @@
 	int fontSize = nHeight / 2;
 	if (fontSize < 8) fontSize = 8;
 
-	// 妫�鏌ュ瓧浣撴槸鍚﹀凡缁忓瓨鍦�
-	auto it = m_mapFonts.find(fontSize);
-	if (it == m_mapFonts.end()) {
-		// 鍔ㄦ�佸垱寤烘柊瀛椾綋
-		CFont* newFont = new CFont();
-		LOGFONT logFont = { 0 };
-		_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
-		logFont.lfHeight = -fontSize;
-		logFont.lfQuality = CLEARTYPE_QUALITY; // 鍚敤 ClearType 鎶楅敮榻�
-		newFont->CreateFontIndirect(&logFont);
+	// 鑾峰彇鎴栧垱寤哄瓧浣�
+	CFont* pFont = GetOrCreateFont(fontSize);
 
-		// 瀛樺偍鍒板瓧浣撶鐞嗗鍣ㄤ腑
-		m_mapFonts[fontSize] = newFont;
-		it = m_mapFonts.find(fontSize);
-	}
-
-	pWnd->SetFont(it->second);
+	pWnd->SetFont(pFont);
 	pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
 }
 
@@ -302,6 +292,7 @@
 	ON_CBN_SELCHANGE(IDC_COMBO_TYPE, &CSystemLogManagerDlg::OnSelchangeComboType)
 	ON_CBN_SELCHANGE(IDC_COMBO_USER, &CSystemLogManagerDlg::OnSelchangeComboUser)
 	ON_WM_SIZE()
+	ON_WM_GETMINMAXINFO()
 END_MESSAGE_MAP()
 
 
@@ -314,9 +305,6 @@
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
 	SetWindowText(_T("绯荤粺杩愯鏃ュ織"));
-
-	// 璁剧疆榛樿瀛椾綋
-	SetDefaultFont();
 
 	m_nCurrentPage = 1;  // 浠庣涓�椤靛紑濮�
 	m_nTotalPages = 1;   // 榛樿鎬婚〉鏁颁负 1
@@ -347,6 +335,34 @@
 	m_nInitialWidth = clientRect.Width();
 	m_nInitialHeight = clientRect.Height();
 
+	// 鍒濆鍖栭粯璁ゅ瓧浣�
+	CFont* pDefaultFont = GetOrCreateFont(12);
+
+	// 閬嶅巻鎵�鏈夊瓙鎺т欢锛岃褰曞垵濮嬩綅缃苟璁剧疆榛樿瀛椾綋
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1) {
+			// 璁板綍鎺т欢鍒濆甯冨眬
+			CRect ctrlRect;
+			pWnd->GetWindowRect(&ctrlRect);
+			ScreenToClient(&ctrlRect);
+			m_mapCtrlLayouts[nCtrlID] = ctrlRect;
+
+			// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
+			TCHAR szClassName[256];
+			GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+			if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+				pWnd = pWnd->GetNextWindow();
+				continue;
+			}
+
+			// 璁剧疆榛樿瀛椾綋
+			pWnd->SetFont(pDefaultFont);
+		}
+		pWnd = pWnd->GetNextWindow();
+	}
+
 	GetWindowRect(&dlgRect);
 	int dlgWidth = dlgRect.Width() * 2;
 	int dlgHeight = dlgRect.Height() * 2;
@@ -375,11 +391,25 @@
 	CDialogEx::OnSize(nType, cx, cy);
 
 	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
-	CRect rect;
-	GetClientRect(&rect);
+	if (nType == SIZE_MINIMIZED || m_mapCtrlLayouts.empty()) {
+		return;
+	}
+
+	float dScaleX = static_cast<float>(cx) / m_nInitialWidth;
+	float dScaleY = static_cast<float>(cy) / m_nInitialHeight;
 
 	// 閬嶅巻瀵硅瘽妗嗕腑鐨勬墍鏈夋帶浠�
-	AdjustControls(rect.Width(), rect.Height());
+	AdjustControls(dScaleX, dScaleY);
+}
+
+
+void CSystemLogManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
+{
+	// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+	lpMMI->ptMinTrackSize.x = 400; // 鏈�灏忓搴�
+	lpMMI->ptMinTrackSize.y = 300; // 鏈�灏忛珮搴�
+
+	CDialogEx::OnGetMinMaxInfo(lpMMI);
 }
 
 
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
index d4acd4c..9cd5ea5 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
@@ -20,9 +20,10 @@
 private:
 	void InitSystemLogManager();
 	void FillSystemLogManager();
+	CFont* GetOrCreateFont(int nFontSize);
 	void UpdatePageInfo();
 	void SetDefaultFont();
-	void AdjustControls(int nWidth, int nHeight);
+	void AdjustControls(float dScaleX, float dScaleY);
 	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
 	void AdjustComboBoxStyle(CComboBox& comboBox);
 	void AdjustDateTimeCtrlStyle(CDateTimeCtrl& dateTimeCtrl);
@@ -32,7 +33,8 @@
 	int m_nInitialHeight;  // 鍒濆楂樺害
 	int m_nCurrentPage;    // 褰撳墠椤电爜
 	int m_nTotalPages;     // 鎬婚〉鏁�
-	std::map<int, CFont*> m_mapFonts; // 绠$悊瀛椾綋鐨勫鍣紝閿负瀛椾綋澶у皬
+	std::map<int, CRect> m_mapCtrlLayouts;	// 瀛樺偍鎺т欢鐨勫垵濮嬪竷灞�淇℃伅
+	std::map<int, CFont*> m_mapFonts;		// 绠$悊瀛椾綋鐨勫鍣紝閿负瀛椾綋澶у皬
 
 private:
 	CComboBox m_comboType;
@@ -50,6 +52,7 @@
 public:
 	virtual BOOL OnInitDialog();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
+	afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
 	afx_msg void OnBnClickedButtonSearch();
 	afx_msg void OnBnClickedButtonPrevPage();
 	afx_msg void OnBnClickedButtonNextPage();
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
index 50136c1..9daa3d1 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
@@ -20,7 +20,8 @@
 CUserManagerDlg::CUserManagerDlg(CWnd* pParent /*=nullptr*/)
 	: CDialogEx(IDD_DIALOG_USER_MANAGER, pParent)
 {
-
+	m_nInitialWidth = 0;
+	m_nInitialHeight = 0;
 }
 
 CUserManagerDlg::~CUserManagerDlg()
@@ -349,25 +350,27 @@
 	return false;
 }
 
+CFont* CUserManagerDlg::GetOrCreateFont(int nFontSize)
+{
+	auto it = m_mapFonts.find(nFontSize);
+	if (it != m_mapFonts.end()) {
+		return it->second;
+	}
+
+	CFont* font = new CFont();
+	LOGFONT logFont = { 0 };
+	_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
+	logFont.lfHeight = -nFontSize;
+	logFont.lfQuality = CLEARTYPE_QUALITY;
+	font->CreateFontIndirect(&logFont);
+	m_mapFonts[nFontSize] = font;
+
+	return font;
+}
+
 void CUserManagerDlg::SetDefaultFont()
 {
-	CFont* defaultFont = nullptr;
-
-	// 濡傛灉瀛椾綋绠$悊瀹瑰櫒涓湁榛樿澶у皬锛堝 12锛夌殑瀛椾綋锛岀洿鎺ヤ娇鐢�
-	auto it = m_mapFonts.find(12);
-	if (it != m_mapFonts.end()) {
-		defaultFont = it->second;
-	}
-	else {
-		// 鍒涘缓榛樿瀛椾綋
-		defaultFont = new CFont();
-		LOGFONT logFont = { 0 };
-		_tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
-		logFont.lfHeight = -12;
-		logFont.lfQuality = CLEARTYPE_QUALITY;
-		defaultFont->CreateFontIndirect(&logFont);
-		m_mapFonts[12] = defaultFont; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
-	}
+	CFont* defaultFont = GetOrCreateFont(12);
 
 	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
 	CWnd* pWnd = GetWindow(GW_CHILD);
@@ -385,41 +388,40 @@
 	}
 }
 
-void CUserManagerDlg::AdjustControls(int nWidth, int nHeight)
+void CUserManagerDlg::AdjustControls(float dScaleX, float dScaleY)
 {
 	CWnd* pWnd = GetWindow(GW_CHILD);
 	while (pWnd) {
-		UINT nCtrlID = pWnd->GetDlgCtrlID();
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1 && m_mapCtrlLayouts.find(nCtrlID) != m_mapCtrlLayouts.end())
+		{
+			CRect originalRect = m_mapCtrlLayouts[nCtrlID];
+			CRect newRect(
+				static_cast<int>(originalRect.left * dScaleX),
+				static_cast<int>(originalRect.top * dScaleY),
+				static_cast<int>(originalRect.right * dScaleX),
+				static_cast<int>(originalRect.bottom * dScaleY));
 
-		CRect ctrlRect;
-		pWnd->GetWindowRect(&ctrlRect);
-		ScreenToClient(&ctrlRect);
+			TCHAR szClassName[256];
+			GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
 
-		// 璁$畻鎺т欢鐨勬柊浣嶇疆鍜屽ぇ灏忥紝鎸夋瘮渚嬭皟鏁�
-		int newX = (int)(ctrlRect.left * (nWidth / (float)m_nInitialWidth));
-		int newY = (int)(ctrlRect.top * (nHeight / (float)m_nInitialHeight));
-		int newWidth = (int)(ctrlRect.Width() * (nWidth / (float)m_nInitialWidth));
-		int newHeight = (int)(ctrlRect.Height() * (nHeight / (float)m_nInitialHeight));
+			if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
+				CComboBox* pComboBox = (CComboBox*)pWnd;
+				pComboBox->SetItemHeight(-1, newRect.Height());  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			}
 
-		TCHAR szClassName[256];
-		GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+			if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+				CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
+				pGridCtrl->SetDefCellHeight(newRect.Height() / 21);
+				pGridCtrl->ExpandColumnsToFit(TRUE);
+				pGridCtrl->ExpandLastColumn();
+				pGridCtrl->Invalidate();
+				pGridCtrl->UpdateWindow();
+			}
 
-		if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
-			CComboBox* pComboBox = (CComboBox*)pWnd;
-			pComboBox->SetItemHeight(-1, nHeight);  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+			pWnd->MoveWindow(&newRect);
+			AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
 		}
-
-		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
-			CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
-			pGridCtrl->SetDefCellHeight(newHeight / 21);
-			pGridCtrl->ExpandColumnsToFit(TRUE);
-			pGridCtrl->Invalidate();
-		}
-
-		pWnd->MoveWindow(newX, newY, newWidth, newHeight);
-		AdjustControlFont(pWnd, newWidth, newHeight);
-
-		// 鑾峰彇涓嬩竴涓帶浠�
 		pWnd = pWnd->GetNextWindow();
 	}
 }
@@ -465,6 +467,7 @@
 	ON_BN_CLICKED(IDC_BUTTON_DEL, &CUserManagerDlg::OnBnClickedButtonDel)
 	ON_BN_CLICKED(IDOK, &CUserManagerDlg::OnBnClickedOk)
 	ON_BN_CLICKED(IDC_BUTTON_INSERT, &CUserManagerDlg::OnBnClickedButtonInsert)
+	ON_WM_GETMINMAXINFO()
 END_MESSAGE_MAP()
 
 
@@ -480,12 +483,37 @@
 	SetWindowText(_T("鐢ㄦ埛绠$悊"));
 	SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
 
-	// 璁剧疆榛樿瀛椾綋
-	SetDefaultFont();
-
 	GetClientRect(&clientRect);
 	m_nInitialWidth = clientRect.Width();
 	m_nInitialHeight = clientRect.Height();
+
+	// 鍒濆鍖栭粯璁ゅ瓧浣�
+	CFont* pDefaultFont = GetOrCreateFont(12);
+
+	// 閬嶅巻鎵�鏈夊瓙鎺т欢锛岃褰曞垵濮嬩綅缃苟璁剧疆榛樿瀛椾綋
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		int nCtrlID = pWnd->GetDlgCtrlID();
+		if (nCtrlID != -1) {
+			// 璁板綍鎺т欢鍒濆甯冨眬
+			CRect ctrlRect;
+			pWnd->GetWindowRect(&ctrlRect);
+			ScreenToClient(&ctrlRect);
+			m_mapCtrlLayouts[nCtrlID] = ctrlRect;
+
+			// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
+			TCHAR szClassName[256];
+			GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+			if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+				pWnd = pWnd->GetNextWindow();
+				continue;
+			}
+
+			// 璁剧疆榛樿瀛椾綋
+			pWnd->SetFont(pDefaultFont);
+		}
+		pWnd = pWnd->GetNextWindow();
+	}
 
 	GetWindowRect(&dlgRect);
 	int dlgWidth = dlgRect.Width() * 3;
@@ -509,17 +537,33 @@
 	// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
 }
 
+
 void CUserManagerDlg::OnSize(UINT nType, int cx, int cy)
 {
 	CDialogEx::OnSize(nType, cx, cy);
 
 	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
-	CRect rect;
-	GetClientRect(&rect);
+	if (nType == SIZE_MINIMIZED || m_mapCtrlLayouts.empty()) {
+		return;
+	}
+
+	float dScaleX = static_cast<float>(cx) / m_nInitialWidth;
+	float dScaleY = static_cast<float>(cy) / m_nInitialHeight;
 
 	// 閬嶅巻瀵硅瘽妗嗕腑鐨勬墍鏈夋帶浠�
-	AdjustControls(rect.Width(), rect.Height());
+	AdjustControls(dScaleX, dScaleY);
 }
+
+
+void CUserManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
+{
+	// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+	lpMMI->ptMinTrackSize.x = 400; // 鏈�灏忓搴�
+	lpMMI->ptMinTrackSize.y = 300; // 鏈�灏忛珮搴�
+
+	CDialogEx::OnGetMinMaxInfo(lpMMI);
+}
+
 
 void CUserManagerDlg::OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult)
 {
@@ -550,11 +594,13 @@
 	*pResult = 0;
 }
 
+
 void CUserManagerDlg::OnBnClickedButtonAdd()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
 	AddRow(&m_gridUserManager);
 }
+
 
 void CUserManagerDlg::OnBnClickedButtonInsert()
 {
@@ -619,12 +665,14 @@
 	m_gridUserManager.UpdateWindow();
 }
 
+
 void CUserManagerDlg::OnBnClickedButtonDel()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
 	DeleteSelectedRow(&m_gridUserManager);
 }
 
+
 void CUserManagerDlg::OnBnClickedOk()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.h b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
index ee87412..c311784 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
@@ -23,13 +23,15 @@
 	void AddRow(CGridCtrl* pGridCtrl);
 	void DeleteSelectedRow(CGridCtrl* pGridCtrl);
 	bool IsUsernameDuplicate(const CString& username);
+	CFont* GetOrCreateFont(int nFontSize);
 	void SetDefaultFont();
-	void AdjustControls(int nWidth, int nHeight);
+	void AdjustControls(float dScaleX, float dScaleY);
 	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
 
 private:
 	int m_nInitialWidth;
 	int m_nInitialHeight;
+	std::map<int, CRect> m_mapCtrlLayouts;
 	std::map<int, CFont*> m_mapFonts;
 	std::map<CString, CString> m_mapRoleDescriptions;
 
@@ -43,6 +45,7 @@
 public:
 	virtual BOOL OnInitDialog();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
+	afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
 	afx_msg void OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult);
 	afx_msg void OnBnClickedButtonAdd();
 	afx_msg void OnBnClickedButtonInsert();

--
Gitblit v1.9.3