1. 提取对话框动态变化控件大小的函数(新建对话框基类)
| | |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ClInclude Include="AlarmPopupDlg.h" /> |
| | | <ClInclude Include="CBaseDlg.h" /> |
| | | <ClInclude Include="CComponentDlg.h" /> |
| | | <ClInclude Include="CComponentPLCDlg.h" /> |
| | | <ClInclude Include="CPLC.h" /> |
| | |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ClCompile Include="AlarmPopupDlg.cpp" /> |
| | | <ClCompile Include="CBaseDlg.cpp" /> |
| | | <ClCompile Include="CComponentDlg.cpp" /> |
| | | <ClCompile Include="CComponentPLCDlg.cpp" /> |
| | | <ClCompile Include="CPLC.cpp" /> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #include "stdafx.h" |
| | | #include "CBaseDlg.h" |
| | | #include "GridCtrl.h" |
| | | |
| | | IMPLEMENT_DYNAMIC(CBaseDlg, CDialogEx) |
| | | |
| | | CBaseDlg::CBaseDlg(UINT id, CWnd* pPage) : CDialogEx(id, pPage) |
| | | { |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | } |
| | | |
| | | CBaseDlg::~CBaseDlg() |
| | | { |
| | | for (auto& pair : m_mapFonts) { |
| | | if (pair.second) { |
| | | pair.second->DeleteObject(); |
| | | delete pair.second; |
| | | } |
| | | } |
| | | m_mapFonts.clear(); |
| | | } |
| | | |
| | | CFont* CBaseDlg::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 CBaseDlg::SetDefaultFont() |
| | | { |
| | | CFont* defaultFont = GetOrCreateFont(12); |
| | | |
| | | // éåæææ§ä»¶ï¼åºç¨é»è®¤åä½ |
| | | 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 CBaseDlg::AdjustControls(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | 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)); |
| | | |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, newRect.Height()); // -1 表示ææé¡¹çé«åº¦ |
| | | } |
| | | |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd; |
| | | pGridCtrl->SetDefCellHeight(newRect.Height() / 21); |
| | | pGridCtrl->ExpandColumnsToFit(TRUE); |
| | | pGridCtrl->ExpandLastColumn(); |
| | | pGridCtrl->Invalidate(); |
| | | pGridCtrl->UpdateWindow(); |
| | | } |
| | | |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CBaseDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight) |
| | | { |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | // è·³è¿ç¹æ®æ§ä»¶ï¼å¦ MFCGridCtrlï¼ |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | return; |
| | | } |
| | | |
| | | // æ ¹æ®æ§ä»¶é«åº¦å¨æè°æ´åä½å¤§å° |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | if (fontSize > 32) fontSize = 32; |
| | | |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | | BEGIN_MESSAGE_MAP(CBaseDlg, CDialogEx) |
| | | ON_WM_SIZE() |
| | | ON_WM_GETMINMAXINFO() |
| | | END_MESSAGE_MAP() |
| | | |
| | | BOOL CBaseDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | CRect screenRect, dlgRect, clientRect; |
| | | SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0); |
| | | |
| | | 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() * 2; |
| | | int dlgHeight = dlgRect.Height() * 2; |
| | | |
| | | 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 |
| | | } |
| | | |
| | | void CBaseDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | 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(dScaleX, dScaleY); |
| | | } |
| | | |
| | | void CBaseDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) |
| | | { |
| | | // TODO: 卿¤æ·»å æ¶æ¯å¤çç¨åºä»£ç å/æè°ç¨é»è®¤å¼ |
| | | lpMMI->ptMinTrackSize.x = 400; // æå°å®½åº¦ |
| | | lpMMI->ptMinTrackSize.y = 300; // æå°é«åº¦ |
| | | |
| | | CDialogEx::OnGetMinMaxInfo(lpMMI); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #pragma once |
| | | |
| | | class CBaseDlg : public CDialogEx |
| | | { |
| | | DECLARE_DYNAMIC(CBaseDlg) |
| | | |
| | | public: |
| | | CBaseDlg(UINT id, CWnd* pPage); // æ åæé 彿° |
| | | virtual ~CBaseDlg(); // ææå½æ° |
| | | |
| | | CFont* GetOrCreateFont(int nFontSize); // è·åæå建åä½ |
| | | void SetDefaultFont(); // 设置é»è®¤åä½ |
| | | |
| | | 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; // æ§ä»¶å¸å± |
| | | |
| | | DECLARE_MESSAGE_MAP() |
| | | public: |
| | | virtual BOOL OnInitDialog(); |
| | | afx_msg void OnSize(UINT nType, int cx, int cy); |
| | | afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); |
| | | }; |
| | |
| | | |
| | | // CAxisDetailSettingsDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CAxisDetailSettingsDlg, CDialogEx) |
| | | IMPLEMENT_DYNAMIC(CAxisDetailSettingsDlg, CBaseDlg) |
| | | |
| | | CAxisDetailSettingsDlg::CAxisDetailSettingsDlg(const CString& strRecipeName, int nAxisNO, CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_AXIS_DETAIL_SETTINGS, pParent) |
| | | : CBaseDlg(IDD_DIALOG_AXIS_DETAIL_SETTINGS, pParent) |
| | | { |
| | | m_strRecipeName = strRecipeName; |
| | | m_nAxisNO = nAxisNO; |
| | | |
| | | m_pPLC = nullptr; |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | } |
| | | |
| | | CAxisDetailSettingsDlg::~CAxisDetailSettingsDlg() |
| | |
| | | |
| | | void CAxisDetailSettingsDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | CBaseDlg::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO); |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription); |
| | | DDX_Control(pDX, IDC_STATIC_START_ADDRESS, m_staticStartAddress); |
| | |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CAxisDetailSettingsDlg, CDialogEx) |
| | | BEGIN_MESSAGE_MAP(CAxisDetailSettingsDlg, CBaseDlg) |
| | | ON_NOTIFY(NM_CLICK, IDC_CUSTOM_AXIS_ANCHOR_POINT, &CAxisDetailSettingsDlg::OnGridItemChanged) |
| | | ON_BN_CLICKED(IDC_BUTTON_AXIS_DETAIL_SETTINGS_SAVE, &CAxisDetailSettingsDlg::OnBnClickedButtonAxisDetailSettingsSave) |
| | | ON_BN_CLICKED(IDC_BUTTON_SET_AXIS_POSITIONING_POINTS, &CAxisDetailSettingsDlg::OnBnClickedButtonSetAxisPositioningPoints) |
| | |
| | | |
| | | BOOL CAxisDetailSettingsDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | CBaseDlg::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | CString strTitle; |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | #include "GridCtrl.h" |
| | | #include "CBaseDlg.h" |
| | | |
| | | |
| | | // CAxisDetailSettingsDlg å¯¹è¯æ¡ |
| | | |
| | | class CAxisDetailSettingsDlg : public CDialogEx |
| | | class CAxisDetailSettingsDlg : public CBaseDlg |
| | | { |
| | | DECLARE_DYNAMIC(CAxisDetailSettingsDlg) |
| | | |
| | |
| | | void FillAnchorPontManager(); |
| | | void UpdateAxisDetailSettings(); |
| | | |
| | | |
| | | private: |
| | | CPLC* m_pPLC; |
| | | int m_nInitialWidth; |
| | | int m_nInitialHeight; |
| | | |
| | | // æ°æ® |
| | | int m_nAxisNO; |
| | |
| | | |
| | | // CAxisSettingsDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CAxisSettingsDlg, CDialogEx) |
| | | IMPLEMENT_DYNAMIC(CAxisSettingsDlg, CBaseDlg) |
| | | |
| | | CAxisSettingsDlg::CAxisSettingsDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_AXIS_SETTINGS, pParent) |
| | | : CBaseDlg(IDD_DIALOG_AXIS_SETTINGS, pParent) |
| | | { |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | m_pPLC = nullptr; |
| | | |
| | | m_bSEV = FALSE; |
| | |
| | | |
| | | CAxisSettingsDlg::~CAxisSettingsDlg() |
| | | { |
| | | for (auto& pair : m_mapFonts) { |
| | | if (pair.second) { |
| | | pair.second->DeleteObject(); |
| | | delete pair.second; |
| | | } |
| | | } |
| | | m_mapFonts.clear(); |
| | | |
| | | for (int i = 0; i < BTN_MAX; i++) { |
| | | delete m_pBlBtns[i]; |
| | | } |
| | |
| | | |
| | | void CAxisSettingsDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | CBaseDlg::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_COMBO_AXIS_NAME, m_comboAxisNO); |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO); |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | 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 = GetOrCreateFont(12); |
| | | |
| | | // éåæææ§ä»¶ï¼åºç¨é»è®¤åä½ |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | pWnd->SetFont(defaultFont, TRUE); |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::AdjustControls(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | 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)); |
| | | |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, newRect.Height()); // -1 表示ææé¡¹çé«åº¦ |
| | | } |
| | | |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight) |
| | | { |
| | | // æ ¹æ®æ§ä»¶é«åº¦å¨æè°æ´åä½å¤§å° |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | if (fontSize > 24) fontSize = 24; // æå¤§åä½å¤§å° |
| | | |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | | void CAxisSettingsDlg::AdjustLabelFont(CBLLabel& label) |
| | | { |
| | | if (label.m_hWnd == nullptr) { |
| | |
| | | // å¨æè®¡ç®åä½å¤§å°ï¼åºäºæ§ä»¶çé«åº¦ |
| | | int fontSize = rect.Height() / 2; // æ§ä»¶é«åº¦çä¸åä½ä¸ºåä½å¤§å° |
| | | if (fontSize < 8) fontSize = 8; // æå°åä½å¤§å° |
| | | if (fontSize > 30) fontSize = 30; // æå¤§åä½å¤§å° |
| | | if (fontSize > 20) fontSize = 20; // æå¤§åä½å¤§å° |
| | | |
| | | // 设置åä½å¤§å° |
| | | label.SetFontSize(fontSize); |
| | |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx) |
| | | BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CBaseDlg) |
| | | ON_BN_CLICKED(IDC_BUTTON_AXIS_LAST, &CAxisSettingsDlg::OnBnClickedButtonAxisLast) |
| | | ON_BN_CLICKED(IDC_BUTTON_AXIS_NEXT, &CAxisSettingsDlg::OnBnClickedButtonAxisNext) |
| | | ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1) |
| | |
| | | ON_BN_CLICKED(IDC_BUTTON_AXIS_DETAIL_SETTINGS, &CAxisSettingsDlg::OnBnClickedButtonAxisDetailSettings) |
| | | ON_MESSAGE(ID_MSG_UPDATA_DATA_TO_UI, &CAxisSettingsDlg::OnUpdateDataToUI) |
| | | ON_WM_SIZE() |
| | | ON_WM_CTLCOLOR() |
| | | ON_WM_SIZING() |
| | | ON_WM_TIMER() |
| | | ON_WM_CLOSE() |
| | | END_MESSAGE_MAP() |
| | |
| | | |
| | | BOOL CAxisSettingsDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | CBaseDlg::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | CString strTitle; |
| | |
| | | pLabel->SetTextColor(RGB(255, 255, 255)); |
| | | pLabel->SetAlignment(AlignCenter); |
| | | pLabel->SetDynamicFont(TRUE); |
| | | |
| | | AdjustLabelFont(*pLabel); |
| | | } |
| | | |
| | | // åå§åç¼è¾æ¡ |
| | |
| | | initializeAxisIDCombo(); |
| | | refreshAxisDetails(1); |
| | | refreshPositionDetails(1, m_currentPage); |
| | | |
| | | 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; |
| | | |
| | | 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); |
| | | |
| | | SetTimer(TIMER_READ_PLC_DATA, 500, nullptr); |
| | | |
| | |
| | | } |
| | | |
| | | if (currentIndex == -1) { |
| | | return CDialogEx::PreTranslateMessage(pMsg); |
| | | return CBaseDlg::PreTranslateMessage(pMsg); |
| | | } |
| | | |
| | | CString descriptionCtrlName, positionCtrlName; |
| | |
| | | CWnd* pPositionCtrl = GetDlgItem(positionCtrlId); |
| | | |
| | | if (pDescriptionCtrl == nullptr || pPositionCtrl == nullptr) { |
| | | return CDialogEx::PreTranslateMessage(pMsg); |
| | | return CBaseDlg::PreTranslateMessage(pMsg); |
| | | } |
| | | |
| | | PositionRange& position = recipeManager.getPositionByIndex(getCurrentSelectedAxisID(), m_currentPage, AXIS_PAGE_SIZE, currentIndex); |
| | |
| | | CString strText; |
| | | GetDlgItem(IDC_EDIT_AXIS_CURR_POS)->GetWindowText(strText); |
| | | if (strText.IsEmpty()) { |
| | | return CDialogEx::PreTranslateMessage(pMsg);; |
| | | return CBaseDlg::PreTranslateMessage(pMsg);; |
| | | } |
| | | |
| | | double enteredValue = _ttof(strText); |
| | |
| | | } |
| | | } |
| | | |
| | | return CDialogEx::PreTranslateMessage(pMsg); |
| | | return CBaseDlg::PreTranslateMessage(pMsg); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | CBaseDlg::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | 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(dScaleX, dScaleY); |
| | | |
| | | // å¨æè°æ´å个 CBLLabel çåä½å¤§å° |
| | | for (auto pLabel : m_pBlLabels) { |
| | | AdjustLabelFont(*pLabel); |
| | |
| | | pComboBox->MoveWindow(&rectComboBox); |
| | | pComboBox->SetItemHeight(-1, rectButton.Height() - 6); |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnSizing(UINT fwSide, LPRECT pRect) |
| | | { |
| | | if (fwSide == WMSZ_BOTTOMRIGHT) { |
| | | if (pRect->right - pRect->left < 200) { |
| | | pRect->right = pRect->left + 200; |
| | | } |
| | | if (pRect->bottom - pRect->top < 150) { |
| | | pRect->bottom = pRect->top + 150; |
| | | } |
| | | } |
| | | |
| | | CDialogEx::OnSizing(fwSide, pRect); |
| | | } |
| | | |
| | | HBRUSH CAxisSettingsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) |
| | | { |
| | | HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor); |
| | | |
| | | // TODO: 卿¤æ´æ¹ DC çä»»ä½ç¹æ§ |
| | | |
| | | // TODO: 妿é»è®¤ç䏿¯æéç»ç¬ï¼åè¿åå¦ä¸ä¸ªç»ç¬ |
| | | return hbr; |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnBnClickedButtonAxisLast() |
| | |
| | | readPLCDataToUI(nAxisId); |
| | | } |
| | | |
| | | CDialogEx::OnTimer(nIDEvent); |
| | | CBaseDlg::OnTimer(nIDEvent); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnClose() |
| | |
| | | // TODO: 卿¤æ·»å æ¶æ¯å¤çç¨åºä»£ç å/æè°ç¨é»è®¤å¼ |
| | | KillTimer(TIMER_READ_PLC_DATA); |
| | | |
| | | CDialogEx::OnClose(); |
| | | CBaseDlg::OnClose(); |
| | | } |
| | |
| | | #include "BLLabel.h" |
| | | #include "RegexEdit.h" |
| | | #include "CPLC.h" |
| | | #include "CBaseDlg.h" |
| | | |
| | | // æ¯é¡µå®ä½ç¹æ¾ç¤ºä¸ªæ° |
| | | #define AXIS_PAGE_SIZE 5 |
| | |
| | | POSITION_5 // å®ä½ç¹5 |
| | | }; |
| | | |
| | | class CAxisSettingsDlg : public CDialogEx |
| | | class CAxisSettingsDlg : public CBaseDlg |
| | | { |
| | | DECLARE_DYNAMIC(CAxisSettingsDlg) |
| | | |
| | |
| | | |
| | | private: |
| | | UINT FindIDByName(const CString& strControlID); |
| | | CFont* GetOrCreateFont(int nFontSize); |
| | | void SetDefaultFont(); |
| | | void AdjustControls(float dScaleX, float dScaleY); |
| | | void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight); |
| | | void AdjustLabelFont(CBLLabel& label); |
| | | void SetLabelColor(CBLLabel& label, COLORREF color); |
| | | void SetLabelColorBasedOnState(CBLLabel& label, BOOL bState, COLORREF colorTrue, COLORREF colorFalse); |
| | |
| | | |
| | | private: |
| | | CPLC* m_pPLC; |
| | | int m_nInitialWidth; |
| | | int m_nInitialHeight; |
| | | |
| | | // å½åéä¸çå®ä½é¡µé¢ç´¢å¼ |
| | | int m_currentPage; |
| | |
| | | CRegexEdit* m_pRegexEdit[EDIT_MAX]; |
| | | CComboBox m_comboAxisNO; |
| | | CStatic m_staticAxisNO, m_staticAxisDescription, m_staticStartAddress; |
| | | //CEdit m_editManualSpeed, m_editAutoSpeed, m_editAccelerationTime, m_editDecelerationTime, m_editJogDistance; |
| | | |
| | | std::map<int, CRect> m_mapCtrlLayouts; |
| | | std::map<int, CFont*> m_mapFonts; |
| | | |
| | | // 读å°çæ°æ® |
| | | BOOL m_bSEV; |
| | |
| | | virtual BOOL OnInitDialog(); |
| | | virtual BOOL PreTranslateMessage(MSG* pMsg); |
| | | afx_msg void OnSize(UINT nType, int cx, int cy); |
| | | afx_msg void OnSizing(UINT fwSide, LPRECT pRect); |
| | | afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); |
| | | afx_msg void OnBnClickedButtonAxisLast(); |
| | | afx_msg void OnBnClickedButtonAxisNext(); |
| | | afx_msg void OnBnClickedButtonAxisAnchorPointGroup1(); |
| | |
| | | |
| | | // CRecipeListDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CRecipeListDlg, CDialogEx) |
| | | IMPLEMENT_DYNAMIC(CRecipeListDlg, CBaseDlg) |
| | | |
| | | CRecipeListDlg::CRecipeListDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_RECIPE_LIST, pParent) |
| | | : CBaseDlg(IDD_DIALOG_RECIPE_LIST, pParent) |
| | | { |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | m_staticCurrRecipe = new CBLLabel(); |
| | | } |
| | | |
| | |
| | | delete m_staticCurrRecipe; |
| | | m_staticCurrRecipe = nullptr; |
| | | } |
| | | |
| | | for (auto& pair : m_mapFonts) { |
| | | if (pair.second) { |
| | | pair.second->DeleteObject(); |
| | | delete pair.second; |
| | | } |
| | | } |
| | | m_mapFonts.clear(); |
| | | } |
| | | |
| | | CFont* CRecipeListDlg::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 CRecipeListDlg::AdjustControls(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | 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)); |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CRecipeListDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight) |
| | | { |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | // è·³è¿ç¹æ®æ§ä»¶ï¼å¦ MFCGridCtrlï¼ |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | return; |
| | | } |
| | | |
| | | // æ ¹æ®æ§ä»¶é«åº¦å¨æè°æ´åä½å¤§å° |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | if (fontSize < 24) fontSize = 24; |
| | | |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | | void CRecipeListDlg::AdjustLabelFont(CBLLabel& label) |
| | |
| | | |
| | | void CRecipeListDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | CBaseDlg::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_CUSTOM_RECIPE_LIST, m_grid); |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CRecipeListDlg, CDialogEx) |
| | | BEGIN_MESSAGE_MAP(CRecipeListDlg, CBaseDlg) |
| | | ON_BN_CLICKED(IDC_BUTTON_CREATE_RECIPE, &CRecipeListDlg::OnBnClickedButtonCreateRecipe) |
| | | ON_BN_CLICKED(IDC_BUTTON_DELETE_RECIPE, &CRecipeListDlg::OnBnClickedButtonDeleteRecipe) |
| | | ON_BN_CLICKED(IDC_BUTTON_SELECT_RECIPE, &CRecipeListDlg::OnBnClickedButtonSelectRecipe) |
| | |
| | | |
| | | BOOL CRecipeListDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | CBaseDlg::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | m_staticCurrRecipe->SubclassDlgItem(IDC_STATIC_CURR_RECIPE, this); |
| | |
| | | m_staticCurrRecipe->SetDynamicFont(TRUE); |
| | | m_staticCurrRecipe->SetWindowText(RecipeManager::getInstance().getCurrentRecipeName().c_str()); |
| | | |
| | | CRect screenRect, dlgRect, clientRect; |
| | | SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0); |
| | | |
| | | 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() * 2; |
| | | int dlgHeight = dlgRect.Height() * 2; |
| | | |
| | | 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); |
| | | AdjustLabelFont(*m_staticCurrRecipe); |
| | | |
| | | InitRecipeLise(); |
| | | |
| | |
| | | |
| | | void CRecipeListDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | CBaseDlg::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | 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(dScaleX, dScaleY); |
| | | AdjustLabelFont(*m_staticCurrRecipe); |
| | | } |
| | | |
| | | |
| | | void CRecipeListDlg::OnBnClickedButtonCreateRecipe() |
| | | { |
| | |
| | | return; |
| | | } |
| | | CString strText = inputDialog.GetInputText(); |
| | | m_grid.SetItemText(nRow, nCol, strText); |
| | | UpdateDataFile(strRecipeName, strText); |
| | | |
| | | m_grid.ExpandColumnsToFit(FALSE); // èªå¨è°æ´å宽 |
| | | m_grid.ExpandLastColumn(); // æåä¸åå¡«å
ç½æ ¼ |
| | | |
| | | // å·æ°ç½æ ¼æ§ä»¶ |
| | | m_grid.Invalidate(); |
| | | m_grid.UpdateWindow(); |
| | | } |
| | | |
| | | *pResult = 0; |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | #include "GridCtrl.h" |
| | | #include "CBaseDlg.h" |
| | | #include "BLLabel.h" |
| | | |
| | | |
| | | // CRecipeListDlg å¯¹è¯æ¡ |
| | | |
| | | class CRecipeListDlg : public CDialogEx |
| | | class CRecipeListDlg : public CBaseDlg |
| | | { |
| | | DECLARE_DYNAMIC(CRecipeListDlg) |
| | | |
| | |
| | | #endif |
| | | |
| | | private: |
| | | CFont* GetOrCreateFont(int nFontSize); |
| | | void AdjustControls(float dScaleX, float dScaleY); |
| | | void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight); |
| | | //CFont* GetOrCreateFont(int nFontSize); |
| | | //void AdjustControls(float dScaleX, float dScaleY); |
| | | //void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight); |
| | | void AdjustLabelFont(CBLLabel& label); |
| | | void InitRecipeLise(); |
| | | void FillRecipeLise(); |
| | | void UpdateDataFile(const CString& strRecipeName, const CString& strNewDescription); |
| | | |
| | | private: |
| | | int m_nInitialWidth; |
| | | int m_nInitialHeight; |
| | | std::map<int, CFont*> m_mapFonts; // å使 å° |
| | | std::map<int, CRect> m_mapCtrlLayouts; // æ§ä»¶å¸å±æ å° |
| | | //int m_nInitialWidth; |
| | | //int m_nInitialHeight; |
| | | //std::map<int, CFont*> m_mapFonts; // å使 å° |
| | | //std::map<int, CRect> m_mapCtrlLayouts; // æ§ä»¶å¸å±æ å° |
| | | |
| | | // æ§ä»¶ |
| | | CBLLabel* m_staticCurrRecipe; |
| | |
| | | |
| | | // CSystemLogManagerDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CSystemLogManagerDlg, CDialogEx) |
| | | IMPLEMENT_DYNAMIC(CSystemLogManagerDlg, CBaseDlg) |
| | | |
| | | CSystemLogManagerDlg::CSystemLogManagerDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_SYSTEM_LOG_MANAGER, pParent) |
| | | : CBaseDlg(IDD_DIALOG_SYSTEM_LOG_MANAGER, pParent) |
| | | { |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | } |
| | | |
| | | CSystemLogManagerDlg::~CSystemLogManagerDlg() |
| | | { |
| | | for (auto& pair : m_mapFonts) { |
| | | if (pair.second) { |
| | | pair.second->DeleteObject(); |
| | | delete pair.second; |
| | | } |
| | | } |
| | | m_mapFonts.clear(); |
| | | } |
| | | |
| | | void CSystemLogManagerDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | CBaseDlg::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType); |
| | | DDX_Control(pDX, IDC_COMBO_USER, m_comboUser); |
| | | DDX_Control(pDX, IDC_DATETIMEPICKER_START, m_dateTimeStart); |
| | |
| | | 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() |
| | | { |
| | | // æ ¼å¼å页ç ä¿¡æ¯ä¸º "å½å页/æ»é¡µæ°" |
| | |
| | | m_staticPageNum.SetWindowText(pageInfo); |
| | | } |
| | | |
| | | void CSystemLogManagerDlg::SetDefaultFont() |
| | | { |
| | | CFont* defaultFont = GetOrCreateFont(12); |
| | | |
| | | // éåæææ§ä»¶ï¼åºç¨é»è®¤åä½ |
| | | 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 CSystemLogManagerDlg::AdjustControls(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | 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)); |
| | | |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, newRect.Height()); // -1 表示ææé¡¹çé«åº¦ |
| | | } |
| | | |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd; |
| | | pGridCtrl->SetDefCellHeight(newRect.Height() / 21); |
| | | pGridCtrl->ExpandColumnsToFit(TRUE); |
| | | pGridCtrl->ExpandLastColumn(); |
| | | pGridCtrl->Invalidate(); |
| | | pGridCtrl->UpdateWindow(); |
| | | } |
| | | |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CSystemLogManagerDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight) |
| | | { |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | // è·³è¿ç¹æ®æ§ä»¶ï¼å¦ MFCGridCtrlï¼ |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | return; |
| | | } |
| | | |
| | | // æ ¹æ®æ§ä»¶é«åº¦å¨æè°æ´åä½å¤§å° |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::AdjustComboBoxStyle(CComboBox& comboBox) |
| | | { |
| | | DWORD dwStyle = comboBox.GetStyle(); |
| | | comboBox.ModifyStyle(0, CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_OWNERDRAWFIXED); |
| | | |
| | | comboBox.Invalidate(); |
| | | comboBox.UpdateWindow(); |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::AdjustDateTimeCtrlStyle(CDateTimeCtrl& dateTimeCtrl) |
| | | { |
| | | dateTimeCtrl.ModifyStyle(0, DTS_RIGHTALIGN); |
| | | dateTimeCtrl.Invalidate(); |
| | | dateTimeCtrl.UpdateWindow(); |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CSystemLogManagerDlg, CDialogEx) |
| | | BEGIN_MESSAGE_MAP(CSystemLogManagerDlg, CBaseDlg) |
| | | ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CSystemLogManagerDlg::OnBnClickedButtonSearch) |
| | | ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CSystemLogManagerDlg::OnBnClickedButtonPrevPage) |
| | | ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CSystemLogManagerDlg::OnBnClickedButtonNextPage) |
| | | 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() |
| | | |
| | | |
| | |
| | | |
| | | BOOL CSystemLogManagerDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | CBaseDlg::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | SetWindowText(_T("ç³»ç»è¿è¡æ¥å¿")); |
| | |
| | | COleDateTime defaultStartTime = currentTime - COleDateTimeSpan(30, 0, 0, 0); |
| | | m_dateTimeStart.SetTime(defaultStartTime); |
| | | |
| | | 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; |
| | | |
| | | // è·³è¿ç¹æ®æ§ä»¶ï¼å¦ 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; |
| | | |
| | | 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); |
| | | |
| | | InitSystemLogManager(); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | 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(dScaleX, dScaleY); |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) |
| | | { |
| | | // TODO: 卿¤æ·»å æ¶æ¯å¤çç¨åºä»£ç å/æè°ç¨é»è®¤å¼ |
| | | lpMMI->ptMinTrackSize.x = 400; // æå°å®½åº¦ |
| | | lpMMI->ptMinTrackSize.y = 300; // æå°é«åº¦ |
| | | |
| | | CDialogEx::OnGetMinMaxInfo(lpMMI); |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnBnClickedButtonSearch() |
| | | { |
| | |
| | | AfxMessageBox(errorMsg, MB_ICONERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnBnClickedButtonPrevPage() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnBnClickedButtonNextPage() |
| | | { |
| | | // TODO: 卿¤æ·»å æ§ä»¶éç¥å¤çç¨åºä»£ç |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnSelchangeComboType() |
| | | { |
| | | // TODO: 卿¤æ·»å æ§ä»¶éç¥å¤çç¨åºä»£ç |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSystemLogManagerDlg::OnSelchangeComboUser() |
| | | { |
| | | // TODO: 卿¤æ·»å æ§ä»¶éç¥å¤çç¨åºä»£ç |
| | |
| | | errorMsg.Format(_T("忢è§è²å¤±è´¥ï¼%s"), CString(ex.what())); |
| | | AfxMessageBox(errorMsg, MB_ICONERROR); |
| | | } |
| | | } |
| | | } |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | #include "GridCtrl.h" |
| | | #include "CBaseDlg.h" |
| | | |
| | | // CSystemLogManagerDlg å¯¹è¯æ¡ |
| | | |
| | | class CSystemLogManagerDlg : public CDialogEx |
| | | class CSystemLogManagerDlg : public CBaseDlg |
| | | { |
| | | DECLARE_DYNAMIC(CSystemLogManagerDlg) |
| | | |
| | |
| | | private: |
| | | void InitSystemLogManager(); |
| | | void FillSystemLogManager(); |
| | | CFont* GetOrCreateFont(int nFontSize); |
| | | void UpdatePageInfo(); |
| | | void SetDefaultFont(); |
| | | void AdjustControls(float dScaleX, float dScaleY); |
| | | void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight); |
| | | void AdjustComboBoxStyle(CComboBox& comboBox); |
| | | void AdjustDateTimeCtrlStyle(CDateTimeCtrl& dateTimeCtrl); |
| | | |
| | | private: |
| | | int m_nInitialWidth; // åå§å®½åº¦ |
| | | int m_nInitialHeight; // åå§é«åº¦ |
| | | int m_nCurrentPage; // å½å页ç |
| | | int m_nTotalPages; // æ»é¡µæ° |
| | | std::map<int, CRect> m_mapCtrlLayouts; // å卿§ä»¶çåå§å¸å±ä¿¡æ¯ |
| | | std::map<int, CFont*> m_mapFonts; // 管çåä½ç容å¨ï¼é®ä¸ºåä½å¤§å° |
| | | |
| | | private: |
| | | CComboBox m_comboType; |
| | |
| | | |
| | | protected: |
| | | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV æ¯æ |
| | | |
| | | 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 void OnBnClickedButtonSearch(); |
| | | afx_msg void OnBnClickedButtonPrevPage(); |
| | | afx_msg void OnBnClickedButtonNextPage(); |
| | | afx_msg void OnSelchangeComboType(); |
| | | afx_msg void OnSelchangeComboUser(); |
| | | DECLARE_MESSAGE_MAP() |
| | | }; |
| | |
| | | #include "InputDialog.h" |
| | | #include "NewCellTypes/GridCellCombo.h" |
| | | #include "NewCellTypes/GridCellNumeric.h" |
| | | |
| | | #include <set> |
| | | |
| | | const COLORREF CURR_USER_BK_COLOR = RGB(0, 255, 0); |
| | | |
| | | // CUserManagerDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CUserManagerDlg, CDialogEx) |
| | | IMPLEMENT_DYNAMIC(CUserManagerDlg, CBaseDlg) |
| | | |
| | | CUserManagerDlg::CUserManagerDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_USER_MANAGER, pParent) |
| | | : CBaseDlg(IDD_DIALOG_USER_MANAGER, pParent) |
| | | { |
| | | m_nInitialWidth = 0; |
| | | m_nInitialHeight = 0; |
| | | } |
| | | |
| | | CUserManagerDlg::~CUserManagerDlg() |
| | | { |
| | | for (auto& pair : m_mapFonts) { |
| | | if (pair.second) { |
| | | pair.second->DeleteObject(); |
| | | delete pair.second; |
| | | } |
| | | } |
| | | m_mapFonts.clear(); |
| | | } |
| | | |
| | | void CUserManagerDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | DDX_Control(pDX, IDC_CUSTOM_USER, m_gridUserManager); |
| | | CDialogEx::DoDataExchange(pDX); |
| | | CBaseDlg::DoDataExchange(pDX); |
| | | } |
| | | |
| | | void CUserManagerDlg::InitUserManager() |
| | |
| | | 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 = GetOrCreateFont(12); |
| | | |
| | | // éåæææ§ä»¶ï¼åºç¨é»è®¤åä½ |
| | | 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(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | 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)); |
| | | |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, newRect.Height()); // -1 表示ææé¡¹çé«åº¦ |
| | | } |
| | | |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd; |
| | | pGridCtrl->SetDefCellHeight(newRect.Height() / 21); |
| | | pGridCtrl->ExpandColumnsToFit(TRUE); |
| | | pGridCtrl->ExpandLastColumn(); |
| | | pGridCtrl->Invalidate(); |
| | | pGridCtrl->UpdateWindow(); |
| | | } |
| | | |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | void CUserManagerDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight) |
| | | { |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | // è·³è¿ç¹æ®æ§ä»¶ï¼å¦ MFCGridCtrlï¼ |
| | | if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) { |
| | | return; |
| | | } |
| | | |
| | | // æ ¹æ®æ§ä»¶é«åº¦å¨æè°æ´åä½å¤§å° |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | | BEGIN_MESSAGE_MAP(CUserManagerDlg, CDialogEx) |
| | | ON_WM_SIZE() |
| | | BEGIN_MESSAGE_MAP(CUserManagerDlg, CBaseDlg) |
| | | ON_NOTIFY(GVN_COMBOSELCHANGE, IDC_CUSTOM_USER, &CUserManagerDlg::OnGridComboSelChange) |
| | | ON_BN_CLICKED(IDC_BUTTON_ADD, &CUserManagerDlg::OnBnClickedButtonAdd) |
| | | 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() |
| | | |
| | | |
| | |
| | | |
| | | BOOL CUserManagerDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | CBaseDlg::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | CRect screenRect, dlgRect, clientRect; |
| | | SetWindowText(_T("ç¨æ·ç®¡ç")); |
| | | SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0); |
| | | |
| | | 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; |
| | | int dlgHeight = dlgRect.Height() * 3; |
| | | |
| | | 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); |
| | | |
| | | // åå§åç¨æ·ç®¡çè¡¨æ ¼ |
| | | InitUserManager(); |
| | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |
| | | |
| | | |
| | | void CUserManagerDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | 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(dScaleX, dScaleY); |
| | | } |
| | | |
| | | |
| | | void CUserManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) |
| | | { |
| | | // TODO: 卿¤æ·»å æ¶æ¯å¤çç¨åºä»£ç å/æè°ç¨é»è®¤å¼ |
| | | lpMMI->ptMinTrackSize.x = 400; // æå°å®½åº¦ |
| | | lpMMI->ptMinTrackSize.y = 300; // æå°é«åº¦ |
| | | |
| | | CDialogEx::OnGetMinMaxInfo(lpMMI); |
| | | } |
| | | |
| | | |
| | | void CUserManagerDlg::OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult) |
| | | { |
| | |
| | | } |
| | | |
| | | userManager.setUsers(vecData); |
| | | CDialogEx::OnOK(); |
| | | CBaseDlg::OnOK(); |
| | | } |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | #include "GridCtrl.h" |
| | | #include "CBaseDlg.h" |
| | | |
| | | // CUserManagerDlg å¯¹è¯æ¡ |
| | | |
| | | class CUserManagerDlg : public CDialogEx |
| | | class CUserManagerDlg : public CBaseDlg |
| | | { |
| | | DECLARE_DYNAMIC(CUserManagerDlg) |
| | | |
| | |
| | | void AddRow(CGridCtrl* pGridCtrl); |
| | | void DeleteSelectedRow(CGridCtrl* pGridCtrl); |
| | | bool IsUsernameDuplicate(const CString& username); |
| | | CFont* GetOrCreateFont(int nFontSize); |
| | | void SetDefaultFont(); |
| | | 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; |
| | | |
| | | private: |
| | | // æ§ä»¶ |
| | | CGridCtrl m_gridUserManager; |
| | | |
| | | protected: |
| | |
| | | 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 void OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult); |
| | | afx_msg void OnBnClickedButtonAdd(); |
| | | afx_msg void OnBnClickedButtonInsert(); |