REPORTBAR.CPP
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:3k
- // ReportBar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "OAM.h"
- #include "ReportBar.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CReportBar
- static char *_gReportType[] = { "操作报告" ,"上报陷阱","错误指示"};
- static char *_gReportType1[] = { "操作报告","系统告警(已屏蔽)", "部件告警(已屏蔽)","接续告警(已屏蔽)" };
- CReportBar::CReportBar()
- {
- }
- CReportBar::~CReportBar()
- {
- }
- BEGIN_MESSAGE_MAP(CReportBar, COAMControlBar)
- //{{AFX_MSG_MAP(CReportBar)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CReportBar message handlers
- int CReportBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (COAMControlBar::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
- if (!m_Report.Create(NULL,"Report",WS_CHILD|WS_VISIBLE,
- CRect(0,0,1024,800), this, 102))
- {
- TRACE0("Failed to create view for m_listExn");
- return -1;
- }
- m_Report.ModifyStyleEx(0,WS_EX_CLIENTEDGE);
- SetChild(&m_Report);
- for(int i = 0; i<sizeof(_gReportType)/sizeof(char *); i++)
- m_Report.GetSheetControl().AddPage(_gReportType[i]);
- COutputReport * pFirstView = (COutputReport *)m_Report.GetSheetControl().GetFirstView();
- if(pFirstView)
- m_Report.GetSheetControl().SetActiveView(pFirstView);
-
- return 0;
- }
- void CReportBar::WriteReportLine(LPCSTR lpBlock, int Type)
- {
- if(!m_Report.GetSheetControl().GetSafeHwnd())
- return;
- int nPage = LOWORD(Type);
- if(nPage>3)
- nPage = 0;
- COutputReport * pEdit = m_Report.GetSheetControl().GetPageAt(nPage);
- if(pEdit)
- {
- CString strLine = CONTROL_BYTE;
- BYTE fClr = min(LOBYTE(HIWORD(Type)),15);
- CString str;
- str.Format("%02d,15%s",fClr,lpBlock);
- strLine += str;
- pEdit->AddLine(strLine);//,HIWORD(Type),TRUE);
- //pEdit->AddLine(strLine);//,HIWORD(Type),TRUE);
- // pEdit->WriteReportLine(lpBlock,0,FALSE);
- if(/*nPage != 0 &&*/ m_Report.GetSheetControl().GetActiveView()!=pEdit)
- {
- pEdit->m_nHasAlert = TRUE;
- m_Report.GetSheetControl().Splash(pEdit);
- }
- else
- {
- m_Report.SendMessage(SM_PAGECHANGED,(WPARAM)pEdit,0);
- }
- }
- }
- void CReportBar::EnableAlert(int nType, BOOL bEnable)
- {
- if(nType<0 || nType>=sizeof(_gReportType)/sizeof(char *))
- return;
- COutputReport * pEdit = m_Report.GetSheetControl().GetPageAt(nType);
- if(pEdit)
- {
- if(bEnable)
- {
- pEdit->SetWindowText(_gReportType[nType]);
- pEdit->m_strName = _gReportType[nType];
- }
- else
- {
- pEdit->SetWindowText(_gReportType1[nType]);
- pEdit->m_strName = _gReportType1[nType];
- }
- m_Report.m_wndSheet.Invalidate();
- }
- }