| | |
| | | GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurPage < m_nTotalPages); |
| | | } |
| | | |
| | | static char* pszAlarmLevel[] = {"Warning", "Error"}; |
| | | void CAlarmDlg::FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<AlarmData>& vecData) |
| | | { |
| | | if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) { |
| | |
| | | // 设置åå
容 |
| | | str.Format(_T("%d"), alarm.nId); |
| | | pListCtrl->SetItemText(nItem, 1, str); // æ¥è¦ID |
| | | str.Format(_T("%d"), alarm.nSeverityLevel); |
| | | pListCtrl->SetItemText(nItem, 2, str); // ç级 |
| | | pListCtrl->SetItemText(nItem, 2, pszAlarmLevel[alarm.nSeverityLevel % 2]); // ç级 |
| | | pListCtrl->SetItemText(nItem, 3, alarm.strDeviceName.c_str()); // 设å¤åç§° |
| | | pListCtrl->SetItemText(nItem, 4, alarm.strUnitName.c_str()); // åå
åç§° |
| | | pListCtrl->SetItemText(nItem, 5, alarm.strStartTime.c_str()); // å¼å§æ¶é´ |
| | |
| | | { |
| | | DDX_Control(pDX, IDC_DATETIMEPICKER_START, m_dateTimeStart); |
| | | DDX_Control(pDX, IDC_DATETIMEPICKER_END, m_dateTimeEnd); |
| | | DDX_Control(pDX, IDC_LIST_ALARM, m_listCtrl); |
| | | CDialogEx::DoDataExchange(pDX); |
| | | } |
| | | |
| | |
| | | m_dateTimeStart.EnableWindow(FALSE); |
| | | m_dateTimeEnd.EnableWindow(FALSE); |
| | | |
| | | |
| | | // 读åºå宽 |
| | | CString strIniFile, strItem; |
| | | strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | int width[8] = { 0, 80, 180, 80, 80, 100, 80, 180}; |
| | | for (int i = 0; i < 8; i++) { |
| | | strItem.Format(_T("Col_%d_Width"), i); |
| | | width[i] = GetPrivateProfileInt("AlarmListCtrl", strItem, width[i], strIniFile); |
| | | } |
| | | |
| | | |
| | | // æ¥è¡¨æ§ä»¶ |
| | | CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM); |
| | | DWORD dwStyle = pListCtrl->GetExtendedStyle(); |
| | |
| | | |
| | | HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1); |
| | | ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL); |
| | | pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); |
| | | pListCtrl->InsertColumn(1, _T("è¦åID"), LVCFMT_LEFT, 50); |
| | | pListCtrl->InsertColumn(2, _T("æ¥è¦ç级"), LVCFMT_LEFT, 60); |
| | | pListCtrl->InsertColumn(3, _T("设å¤åç§°"), LVCFMT_LEFT, 100); |
| | | pListCtrl->InsertColumn(4, _T("åå
åç§°"), LVCFMT_LEFT, 100); |
| | | pListCtrl->InsertColumn(5, _T("åçæ¶é´"), LVCFMT_LEFT, 120); |
| | | pListCtrl->InsertColumn(6, _T("è§£é¤æ¶é´"), LVCFMT_LEFT, 120); |
| | | pListCtrl->InsertColumn(7, _T("æè¿°"), LVCFMT_LEFT, 180); |
| | | pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]); |
| | | pListCtrl->InsertColumn(1, _T("è¦åID"), LVCFMT_LEFT, width[1]); |
| | | pListCtrl->InsertColumn(2, _T("æ¥è¦ç级"), LVCFMT_LEFT, width[2]); |
| | | pListCtrl->InsertColumn(3, _T("设å¤åç§°"), LVCFMT_LEFT, width[3]); |
| | | pListCtrl->InsertColumn(4, _T("åå
åç§°"), LVCFMT_LEFT, width[4]); |
| | | pListCtrl->InsertColumn(5, _T("åçæ¶é´"), LVCFMT_LEFT, width[5]); |
| | | pListCtrl->InsertColumn(6, _T("è§£é¤æ¶é´"), LVCFMT_LEFT, width[6]); |
| | | pListCtrl->InsertColumn(7, _T("æè¿°"), LVCFMT_LEFT, width[7]); |
| | | pListCtrl->SetColumnWidth(7, LVSCW_AUTOSIZE_USEHEADER); |
| | | |
| | | |
| | | |
| | | // è®¡ç®æ»é¡µæ° |
| | | int totalRecords = AlarmManager::getInstance().getTotalAlarmCount("", "", m_strDeviceName, m_strUnitName, m_strKeyword, m_szTimeStart, m_szTimeEnd); |
| | |
| | | { |
| | | CDialogEx::OnDestroy(); |
| | | |
| | | |
| | | // ä¿åå宽 |
| | | CString strIniFile, strItem, strTemp; |
| | | strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl(); |
| | | for (int i = 0; i < pHeader->GetItemCount(); i++) { |
| | | RECT rect; |
| | | pHeader->GetItemRect(i, &rect); |
| | | strItem.Format(_T("Col_%d_Width"), i); |
| | | strTemp.Format(_T("%d"), rect.right - rect.left); |
| | | WritePrivateProfileString("AlarmListCtrl", strItem, strTemp, strIniFile); |
| | | } |
| | | |
| | | |
| | | if (m_hbrBkgnd != nullptr) { |
| | | ::DeleteObject(m_hbrBkgnd); |
| | | } |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | #include "AlarmManager.h" |
| | | #include "ListCtrlEx.h" |
| | | |
| | | |
| | | #define ID_MSG_ALARMDLG_HIDE WM_USER + 1024 |
| | |
| | | // æ§ä»¶ |
| | | CDateTimeCtrl m_dateTimeStart; |
| | | CDateTimeCtrl m_dateTimeEnd; |
| | | CListCtrlEx m_listCtrl; |
| | | |
| | | // å¯¹è¯æ¡æ°æ® |
| | | #ifdef AFX_DESIGN_TIME |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #include "stdafx.h" |
| | | #include "ListCtrlEx.h" |
| | | |
| | | |
| | | CListCtrlEx::CListCtrlEx() |
| | | { |
| | | } |
| | | |
| | | |
| | | CListCtrlEx::~CListCtrlEx() |
| | | { |
| | | } |
| | | BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl) |
| | | ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CListCtrlEx::OnNMCustomdraw) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | | void CListCtrlEx::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) |
| | | { |
| | | LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); |
| | | // TODO: 卿¤æ·»å æ§ä»¶éç¥å¤çç¨åºä»£ç |
| | | *pResult = CDRF_DODEFAULT; |
| | | |
| | | NMLVCUSTOMDRAW * lplvdr = (NMLVCUSTOMDRAW*)pNMHDR; |
| | | NMCUSTOMDRAW &nmcd = lplvdr->nmcd; |
| | | switch (lplvdr->nmcd.dwDrawStage)//å¤æç¶æ |
| | | { |
| | | case CDDS_PREPAINT: |
| | | { |
| | | *pResult = CDRF_NOTIFYITEMDRAW; |
| | | break; |
| | | } |
| | | case CDDS_ITEMPREPAINT://å¦æä¸ºç»ITEMä¹åå°±è¦è¿è¡é¢è²çæ¹å |
| | | { |
| | | // æ ¹æ®å¨ SetItemColor(DWORD iItem, COLORREF color) 设置ç |
| | | // ITEMå·åCOLORREF 卿¸æ¿ä¸æ¥æ¾ï¼ç¶åè¿è¡é¢è²èµå¼ã |
| | | //LISTITEMEX_9& itemex = m_listItemColor.GetAt(m_listItemColor.FindIndex(nmcd.dwItemSpec)); |
| | | //lplvdr->clrText = itemex.colText; |
| | | //lplvdr->clrTextBk = itemex.colTextBk; |
| | | //*pResult = CDRF_DODEFAULT; |
| | | |
| | | if (nmcd.dwItemSpec % 2 == 0) { |
| | | lplvdr->clrText = RGB(0, 0, 0); |
| | | lplvdr->clrTextBk = RGB(235, 235, 235); |
| | | *pResult = CDRF_DODEFAULT; |
| | | } |
| | | else { |
| | | lplvdr->clrText = RGB(0, 0, 0); |
| | | lplvdr->clrTextBk = RGB(255, 255, 255); |
| | | *pResult = CDRF_DODEFAULT; |
| | | } |
| | | |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void CListCtrlEx::SetItemColor(DWORD_PTR iItem, COLORREF TextColor, COLORREF TextBkColor) |
| | | { |
| | | if (iItem >= m_listItemColor.GetSize()) return; |
| | | LISTITEMEX_9& itemex = m_listItemColor.GetAt(m_listItemColor.FindIndex(iItem)); |
| | | itemex.colText = TextColor; |
| | | itemex.colTextBk = TextBkColor; |
| | | this->RedrawItems(iItem, iItem); // éæ°æè² |
| | | UpdateWindow(); |
| | | } |
| | | |
| | | |
| | | LRESULT CListCtrlEx::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) |
| | | { |
| | | int nRet = CListCtrl::WindowProc(message, wParam, lParam); |
| | | if (message == LVM_INSERTITEM) { |
| | | if (nRet != -1) { |
| | | LISTITEMEX_9 itemex = {RGB(0,0,0), RGB(255, 255, 255)}; |
| | | LVITEM* p = (LVITEM*)lParam; |
| | | m_listItemColor.InsertBefore(m_listItemColor.FindIndex(p->iItem), itemex); |
| | | } |
| | | } |
| | | else if (message == LVM_DELETEITEM) { |
| | | if (nRet != 0) { |
| | | m_listItemColor.RemoveAt(m_listItemColor.FindIndex(wParam)); |
| | | } |
| | | } |
| | | else if (message == LVM_DELETEALLITEMS) { |
| | | if (nRet != 0) { |
| | | m_listItemColor.RemoveAll(); |
| | | } |
| | | } |
| | | |
| | | return nRet; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #pragma once |
| | | #include "afxcmn.h" |
| | | |
| | | typedef struct |
| | | { |
| | | COLORREF colText; |
| | | COLORREF colTextBk; |
| | | } LISTITEMEX_9; |
| | | |
| | | class CListCtrlEx : |
| | | public CListCtrl |
| | | { |
| | | public: |
| | | CListCtrlEx(); |
| | | ~CListCtrlEx(); |
| | | |
| | | public: |
| | | void SetItemColor(DWORD_PTR iItem, COLORREF TextColor, COLORREF TextBkColor); |
| | | |
| | | |
| | | private: |
| | | CList<LISTITEMEX_9, LISTITEMEX_9&> m_listItemColor; |
| | | |
| | | private: |
| | | DECLARE_MESSAGE_MAP() |
| | | afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult); |
| | | virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); |
| | | }; |
| | | |
| | |
| | | <ClInclude Include="Context.h" /> |
| | | <ClInclude Include="HsmsAction.h" /> |
| | | <ClInclude Include="HsmsPassive.h" /> |
| | | <ClInclude Include="ListCtrlEx.h" /> |
| | | <ClInclude Include="Log.h" /> |
| | | <ClInclude Include="LogDlg.h" /> |
| | | <ClInclude Include="LogEdit.h" /> |
| | |
| | | <ClCompile Include="Context.cpp" /> |
| | | <ClCompile Include="HsmsAction.cpp" /> |
| | | <ClCompile Include="HsmsPassive.cpp" /> |
| | | <ClCompile Include="ListCtrlEx.cpp" /> |
| | | <ClCompile Include="Log.cpp" /> |
| | | <ClCompile Include="LogDlg.cpp" /> |
| | | <ClCompile Include="LogEdit.cpp" /> |
| | |
| | | <ClCompile Include="CWriteStep.cpp" /> |
| | | <ClCompile Include="CEqCimModeChangeStep.cpp" /> |
| | | <ClCompile Include="CPanelEquipment.cpp" /> |
| | | <ClCompile Include="ListCtrlEx.cpp" /> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ClInclude Include="AlarmManager.h" /> |
| | |
| | | <ClInclude Include="CWriteStep.h" /> |
| | | <ClInclude Include="CEqCimModeChangeStep.h" /> |
| | | <ClInclude Include="CPanelEquipment.h" /> |
| | | <ClInclude Include="ListCtrlEx.h" /> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ResourceCompile Include="Servo.rc" /> |