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/AxisSettingsDlg.cpp | 119 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 60 insertions(+), 59 deletions(-)
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;
--
Gitblit v1.9.3