From 07b2cefe6e0dfe8bc530aab3b58d4159502ceba8 Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期四, 21 十一月 2024 11:34:54 +0800
Subject: [PATCH] 1. 解决控件字体修改以后出现锯齿

---
 SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp |   99 ++++++++-----
 SourceCode/Bond/BondEq/AxisSettingsDlg.cpp          |  178 ++++++++++++++++--------
 SourceCode/Bond/BondEq/Resource.h                   |    0 
 SourceCode/Bond/BondEq/AxisSettingsDlg.h            |   18 +-
 SourceCode/Bond/BondEq/View/UserManagerDlg.h        |    2 
 SourceCode/Bond/BondEq/BondEq.rc                    |    0 
 SourceCode/Bond/BondEq/View/UserManagerDlg.cpp      |   90 ++++++++++--
 SourceCode/Bond/BondEq/BondEqDlg.cpp                |   10 
 SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h   |    2 
 9 files changed, 267 insertions(+), 132 deletions(-)

diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
index e92cb8c..867e469 100644
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
@@ -20,11 +20,104 @@
 
 CAxisSettingsDlg::~CAxisSettingsDlg()
 {
+	for (auto& pair : m_mapFonts) {
+		if (pair.second) {
+			pair.second->DeleteObject();
+			delete pair.second;
+		}
+	}
+	m_mapFonts.clear();
 }
 
 void CAxisSettingsDlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
+}
+
+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; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
+	}
+
+	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		pWnd->SetFont(defaultFont, TRUE);
+		pWnd = pWnd->GetNextWindow();
+	}
+}
+
+void CAxisSettingsDlg::AdjustControls(int nWidth, int nHeight)
+{
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		UINT nCtrlID = pWnd->GetDlgCtrlID();
+
+		CRect ctrlRect;
+		pWnd->GetWindowRect(&ctrlRect);
+		ScreenToClient(&ctrlRect);
+
+		// 璁$畻鎺т欢鐨勬柊浣嶇疆鍜屽ぇ灏忥紝鎸夋瘮渚嬭皟鏁�
+		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));
+
+		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(newX, newY, newWidth, newHeight);
+		AdjustControlFont(pWnd, newWidth, newHeight);
+
+		// 鑾峰彇涓嬩竴涓帶浠�
+		pWnd = pWnd->GetNextWindow();
+	}
+}
+
+void CAxisSettingsDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
+{
+	// 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
+	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);
+
+		// 瀛樺偍鍒板瓧浣撶鐞嗗鍣ㄤ腑
+		m_mapFonts[fontSize] = newFont;
+		it = m_mapFonts.find(fontSize);
+	}
+
+	pWnd->SetFont(it->second);
+	pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
 }
 
 
@@ -61,15 +154,29 @@
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
 	//ModifyStyle(0, WS_THICKFRAME | WS_SIZEBOX);
 
-	CRect rect;
-	GetClientRect(&rect);
-	m_nInitialWidth = rect.Width();
-	m_nInitialHeight = rect.Height();
+	// 璁剧疆榛樿瀛椾綋
+	SetDefaultFont();
 
-	rect.right *= 1.5;
-	rect.bottom *= 1.5;
-	// 璋冩暣瀵硅瘽妗嗗ぇ灏�
-	MoveWindow(rect);
+	CRect screenRect, dlgRect, clientRect;
+	GetClientRect(&clientRect);
+	m_nInitialWidth = clientRect.Width();
+	m_nInitialHeight = clientRect.Height();
+
+	GetWindowRect(&dlgRect);
+	int dlgWidth = dlgRect.Width() * 2;
+	int dlgHeight = dlgRect.Height() * 2;
+
+	SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
+	if (dlgWidth > screenRect.Width()) {
+		dlgWidth = screenRect.Width();
+	}
+	if (dlgHeight > screenRect.Height()) {
+		dlgHeight = screenRect.Height();
+	}
+
+	int centerX = screenRect.left + (screenRect.Width() - dlgWidth) / 2;
+	int centerY = screenRect.top + (screenRect.Height() - dlgHeight) / 2;
+	MoveWindow(centerX, centerY, dlgWidth, dlgHeight);
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 	// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -189,57 +296,4 @@
 void CAxisSettingsDlg::OnBnClickedButtonAxisTestStop()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
-}
-
-void CAxisSettingsDlg::AdjustControls(int nWidth, int nHeight)
-{
-	CWnd* pWnd = GetWindow(GW_CHILD);
-	while (pWnd) {
-		UINT nCtrlID = pWnd->GetDlgCtrlID();
-
-		CRect ctrlRect;
-		pWnd->GetWindowRect(&ctrlRect);
-		ScreenToClient(&ctrlRect);
-
-		// 璁$畻鎺т欢鐨勬柊浣嶇疆鍜屽ぇ灏忥紝鎸夋瘮渚嬭皟鏁�
-		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));
-
-		pWnd->MoveWindow(newX, newY, newWidth, newHeight);
-		AdjustControlFont(pWnd, newWidth, newHeight);
-
-		// 鑾峰彇涓嬩竴涓帶浠�
-		pWnd = pWnd->GetNextWindow();
-	}
-}
-
-void CAxisSettingsDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
-{
-	TCHAR szClassName[256];
-	GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-
-	if (_tcsicmp(szClassName, _T("Static")) == 0) {
-		CStatic* pStatic = (CStatic*)pWnd;
-		pStatic->ModifyStyle(0, SS_CENTER | SS_CENTERIMAGE);
-		return;
-	}
-
-	if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
-		CComboBox* pComboBox = (CComboBox*)pWnd;
-		pComboBox->SetItemHeight(-1, nHeight);  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
-	}
-
-	int fontSize = nHeight - 10;
-	CFont* pCurrentFont = pWnd->GetFont();
-	LOGFONT logFont;
-	pCurrentFont->GetLogFont(&logFont);
-	logFont.lfHeight = -fontSize;
-
-	CFont newFont;
-	newFont.CreateFontIndirect(&logFont);
-
-	pWnd->SetFont(&newFont);
-	pWnd->Invalidate();
-}
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/AxisSettingsDlg.h
index 793b693..5072027 100644
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/AxisSettingsDlg.h
@@ -17,6 +17,16 @@
 	enum { IDD = IDD_DIALOG_AXIS_SETTINGS };
 #endif
 
+private:
+	void SetDefaultFont();
+	void AdjustControls(int nWidth, int nHeight);
+	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
+
+private:
+	int m_nInitialWidth;
+	int m_nInitialHeight;
+	std::map<int, CFont*> m_mapFonts; // 绠$悊瀛椾綋鐨勫鍣紝閿负瀛椾綋澶у皬
+
 protected:
 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
 	virtual BOOL OnInitDialog();
@@ -40,12 +50,4 @@
 	afx_msg void OnBnClickedButtonAxisTestJogSub();
 	afx_msg void OnBnClickedButtonAxisTestStop();
 	DECLARE_MESSAGE_MAP()
-
-private:
-	void AdjustControls(int nWidth, int nHeight);
-	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
-
-private:
-	int m_nInitialWidth;
-	int m_nInitialHeight;
 };
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index 4c7a132..727ece9 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index f1c4cd6..21722d8 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -572,10 +572,6 @@
 			loginDlg.DoModal();
 		}
 		else if (1 == menuId) {
-			// test 
-			CSystemLogManagerDlg dlg;
-			dlg.DoModal();
-
 			CChangePasswordDlg changePasswordDlg;
 			changePasswordDlg.DoModal();
 		}
@@ -586,6 +582,10 @@
 			}
 		}
 		else if (3 == menuId) {
+			CSystemLogManagerDlg dlg;
+			dlg.DoModal();
+		}
+		else if (4 == menuId) {
 			int ret = AfxMessageBox(_T("是否切换用户?切换用户会退出当前账号!"), MB_OKCANCEL | MB_ICONEXCLAMATION);
 			if (ret != IDOK) {
 				return 0;
@@ -692,6 +692,7 @@
 	{
 		::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
 		::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_ENABLED);
+		::EnableMenuItem(hMenu, ID_OPERATOR_SYSTEM_LOG, MF_BYCOMMAND | MF_ENABLED);
 		::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_ENABLED);
 		::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_ENABLED);
 
@@ -708,6 +709,7 @@
 		::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_ENABLED);
 		::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
 		::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+		::EnableMenuItem(hMenu, ID_OPERATOR_SYSTEM_LOG, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
 		::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
 		::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
 
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 4f930a8..7394cbf 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
index db8da77..004e2d8 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
@@ -5,8 +5,6 @@
 #include "BondEq.h"
 #include "afxdialogex.h"
 #include "SystemLogManagerDlg.h"
-#include "UserManager.h"
-#include "SystemLogManager.h"
 
 
 // CSystemLogManagerDlg 瀵硅瘽妗�
@@ -21,6 +19,13 @@
 
 CSystemLogManagerDlg::~CSystemLogManagerDlg()
 {
+	for (auto& pair : m_mapFonts) {
+		if (pair.second) {
+			pair.second->DeleteObject();
+			delete pair.second;
+		}
+	}
+	m_mapFonts.clear();
 }
 
 void CSystemLogManagerDlg::DoDataExchange(CDataExchange* pDX)
@@ -61,13 +66,13 @@
 	m_listLogs.SetFixedColumnCount(nFixCols);
 
 	// Col
-	m_listLogs.SetColumnWidth(nColIdx, 20);
+	m_listLogs.SetColumnWidth(nColIdx, 10);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("No."));
-	m_listLogs.SetColumnWidth(nColIdx, 70);
+	m_listLogs.SetColumnWidth(nColIdx, 10);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("绫诲瀷"));
-	m_listLogs.SetColumnWidth(nColIdx, 150);
+	m_listLogs.SetColumnWidth(nColIdx, 200);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("浜嬩欢"));
-	m_listLogs.SetColumnWidth(nColIdx, 70);
+	m_listLogs.SetColumnWidth(nColIdx, 30);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("鐢ㄦ埛"));
 	m_listLogs.SetColumnWidth(nColIdx, 70);
 	m_listLogs.SetItemText(nRowIdx, nColIdx++, _T("鏃堕棿"));
@@ -164,29 +169,36 @@
 
 void CSystemLogManagerDlg::SetDefaultFont()
 {
-	CFont* pFont = new CFont();
-	LOGFONT logFont = { 0 };
+	CFont* defaultFont = nullptr;
 
-	// 璁剧疆瀛椾綋灞炴��
-	_tcscpy_s(logFont.lfFaceName, _T("Segoe UI")); // 浣跨敤娓呮櫚瀛椾綋
-	logFont.lfHeight = -12; // 瀛椾綋楂樺害
-	logFont.lfWeight = FW_NORMAL;
-	logFont.lfQuality = CLEARTYPE_QUALITY; // 鍚敤 ClearType 鎶楅敮榻�
+	// 濡傛灉瀛椾綋绠$悊瀹瑰櫒涓湁榛樿澶у皬锛堝 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; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
+	}
 
-	pFont->CreateFontIndirect(&logFont);
-
-	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤瀛椾綋
+	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
 	CWnd* pWnd = GetWindow(GW_CHILD);
 	while (pWnd) {
+		// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
 		TCHAR szClassName[256];
 		GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0 
-			|| _tcsicmp(szClassName, _T("ComboBoxs")) == 0) {
+		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
 			pWnd = pWnd->GetNextWindow();
 			continue;
 		}
 
-		pWnd->SetFont(pFont, TRUE);
+		pWnd->SetFont(defaultFont, TRUE);
 		pWnd = pWnd->GetNextWindow();
 	}
 }
@@ -210,6 +222,10 @@
 		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 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+		}
 
 		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
 			CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
@@ -231,32 +247,33 @@
 	TCHAR szClassName[256];
 	GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
 
-	if (_tcsicmp(szClassName, _T("Static")) == 0) {
-		CStatic* pStatic = (CStatic*)pWnd;
-		pStatic->ModifyStyle(SS_CENTER | SS_RIGHT | SS_CENTERIMAGE, SS_LEFT | SS_CENTERIMAGE);
-		return;
-	}
-
-	if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
-		CComboBox* pComboBox = (CComboBox*)pWnd;
-		pComboBox->SetItemHeight(-1, nHeight);  // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
-	}
-
+	// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
 	if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
 		return;
 	}
 
-	int fontSize = nHeight - 10;
-	CFont* pCurrentFont = pWnd->GetFont();
-	LOGFONT logFont;
-	pCurrentFont->GetLogFont(&logFont);
-	logFont.lfHeight = -fontSize;
+	// 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
+	int fontSize = nHeight / 2;
+	if (fontSize < 8) fontSize = 8;
 
-	CFont newFont;
-	newFont.CreateFontIndirect(&logFont);
+	// 妫�鏌ュ瓧浣撴槸鍚﹀凡缁忓瓨鍦�
+	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);
 
-	pWnd->SetFont(&newFont);
-	pWnd->Invalidate();
+		// 瀛樺偍鍒板瓧浣撶鐞嗗鍣ㄤ腑
+		m_mapFonts[fontSize] = newFont;
+		it = m_mapFonts.find(fontSize);
+	}
+
+	pWnd->SetFont(it->second);
+	pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
 }
 
 
@@ -297,6 +314,9 @@
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
 	SetWindowText(_T("绯荤粺杩愯鏃ュ織"));
+
+	// 璁剧疆榛樿瀛椾綋
+	SetDefaultFont();
 
 	m_nCurrentPage = 1;  // 浠庣涓�椤靛紑濮�
 	m_nTotalPages = 1;   // 榛樿鎬婚〉鏁颁负 1
@@ -360,7 +380,6 @@
 
 	// 閬嶅巻瀵硅瘽妗嗕腑鐨勬墍鏈夋帶浠�
 	AdjustControls(rect.Width(), rect.Height());
-	//SetDefaultFont();
 }
 
 
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
index cf73a70..d4acd4c 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
@@ -2,7 +2,6 @@
 #include "afxdialogex.h"
 #include "GridCtrl.h"
 
-
 // CSystemLogManagerDlg 瀵硅瘽妗�
 
 class CSystemLogManagerDlg : public CDialogEx
@@ -33,6 +32,7 @@
 	int m_nInitialHeight;  // 鍒濆楂樺害
 	int m_nCurrentPage;    // 褰撳墠椤电爜
 	int m_nTotalPages;     // 鎬婚〉鏁�
+	std::map<int, CFont*> m_mapFonts; // 绠$悊瀛椾綋鐨勫鍣紝閿负瀛椾綋澶у皬
 
 private:
 	CComboBox m_comboType;
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
index 512eb5e..50136c1 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
@@ -25,6 +25,13 @@
 
 CUserManagerDlg::~CUserManagerDlg()
 {
+	for (auto& pair : m_mapFonts) {
+		if (pair.second) {
+			pair.second->DeleteObject();
+			delete pair.second;
+		}
+	}
+	m_mapFonts.clear();
 }
 
 void CUserManagerDlg::DoDataExchange(CDataExchange* pDX)
@@ -342,6 +349,42 @@
 	return false;
 }
 
+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; // 瀛樺偍鍒板瓧浣撶鐞嗗鍣�
+	}
+
+	// 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
+	CWnd* pWnd = GetWindow(GW_CHILD);
+	while (pWnd) {
+		// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
+		TCHAR szClassName[256];
+		GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+			pWnd = pWnd->GetNextWindow();
+			continue;
+		}
+
+		pWnd->SetFont(defaultFont, TRUE);
+		pWnd = pWnd->GetNextWindow();
+	}
+}
+
 void CUserManagerDlg::AdjustControls(int nWidth, int nHeight)
 {
 	CWnd* pWnd = GetWindow(GW_CHILD);
@@ -361,10 +404,14 @@
 		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 琛ㄧず鎵�鏈夐」鐨勯珮搴�
+		}
 
 		if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
 			CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
-			pGridCtrl->SetDefCellHeight(newHeight / 20);
+			pGridCtrl->SetDefCellHeight(newHeight / 21);
 			pGridCtrl->ExpandColumnsToFit(TRUE);
 			pGridCtrl->Invalidate();
 		}
@@ -382,27 +429,33 @@
 	TCHAR szClassName[256];
 	GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
 
-	if (_tcsicmp(szClassName, _T("Static")) == 0) {
-		CStatic* pStatic = (CStatic*)pWnd;
-		pStatic->ModifyStyle(0, SS_CENTER | SS_CENTERIMAGE);
-		return;
-	}
-
+	// 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
 	if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
 		return;
 	}
 
-	int fontSize = nHeight - 10;
-	CFont* pCurrentFont = pWnd->GetFont();
-	LOGFONT logFont;
-	pCurrentFont->GetLogFont(&logFont);
-	logFont.lfHeight = -fontSize;
+	// 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
+	int fontSize = nHeight / 2;
+	if (fontSize < 8) fontSize = 8;
 
-	CFont newFont;
-	newFont.CreateFontIndirect(&logFont);
+	// 妫�鏌ュ瓧浣撴槸鍚﹀凡缁忓瓨鍦�
+	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);
 
-	pWnd->SetFont(&newFont);
-	pWnd->Invalidate();
+		// 瀛樺偍鍒板瓧浣撶鐞嗗鍣ㄤ腑
+		m_mapFonts[fontSize] = newFont;
+		it = m_mapFonts.find(fontSize);
+	}
+
+	pWnd->SetFont(it->second);
+	pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
 }
 
 BEGIN_MESSAGE_MAP(CUserManagerDlg, CDialogEx)
@@ -427,6 +480,9 @@
 	SetWindowText(_T("鐢ㄦ埛绠$悊"));
 	SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
 
+	// 璁剧疆榛樿瀛椾綋
+	SetDefaultFont();
+
 	GetClientRect(&clientRect);
 	m_nInitialWidth = clientRect.Width();
 	m_nInitialHeight = clientRect.Height();
@@ -436,7 +492,7 @@
 	int dlgHeight = dlgRect.Height() * 3;
 
 	if (dlgWidth > screenRect.Width()) {
-		dlgWidth = screenRect.Width();
+		dlgWidth = screenRect.Width(); 
 	}
 	if (dlgHeight > screenRect.Height()) {
 		dlgHeight = screenRect.Height();
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.h b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
index 3f0ac6a..ee87412 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
@@ -23,12 +23,14 @@
 	void AddRow(CGridCtrl* pGridCtrl);
 	void DeleteSelectedRow(CGridCtrl* pGridCtrl);
 	bool IsUsernameDuplicate(const CString& username);
+	void SetDefaultFont();
 	void AdjustControls(int nWidth, int nHeight);
 	void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
 
 private:
 	int m_nInitialWidth;
 	int m_nInitialHeight;
+	std::map<int, CFont*> m_mapFonts;
 	std::map<CString, CString> m_mapRoleDescriptions;
 
 private:

--
Gitblit v1.9.3