a
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
// appdatatdgrlistview.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "appdatatdgrlistview.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
extern int g_iCurrListColIndex;
|
||||
extern int g_iCurrListColOrder;
|
||||
extern int CALLBACK ListStrCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lSortObject);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAppDataTdGrListView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CAppDataTdGrListView, CListView)
|
||||
|
||||
CAppDataTdGrListView::CAppDataTdGrListView()
|
||||
{
|
||||
m_pMngFrm = NULL;
|
||||
}
|
||||
|
||||
CAppDataTdGrListView::~CAppDataTdGrListView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAppDataTdGrListView, CListView)
|
||||
//{{AFX_MSG_MAP(CAppDataTdGrListView)
|
||||
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
|
||||
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDrawList)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAppDataTdGrListView drawing
|
||||
|
||||
void CAppDataTdGrListView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CDocument* pDoc = GetDocument();
|
||||
// TODO: add draw code here
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAppDataTdGrListView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CAppDataTdGrListView::AssertValid() const
|
||||
{
|
||||
CListView::AssertValid();
|
||||
}
|
||||
|
||||
void CAppDataTdGrListView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CListView::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAppDataTdGrListView message handlers
|
||||
|
||||
void CAppDataTdGrListView::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
||||
// TODO: Add your control notification handler code here
|
||||
g_iCurrListColIndex = pNMListView->iSubItem;
|
||||
g_iCurrListColOrder = !g_iCurrListColOrder;
|
||||
GetListCtrl().SortItems(ListStrCompare, (LPARAM)&GetListCtrl());
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CAppDataTdGrListView::OnInitialUpdate()
|
||||
{
|
||||
CListView::OnInitialUpdate();
|
||||
|
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
CString strColTitle;
|
||||
int iColIndex = (int)VAL_ZERO;
|
||||
|
||||
GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
||||
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
|
||||
|
||||
m_pMngFrm = (CMDIChildWnd*)GetParentFrame();
|
||||
|
||||
g_iCurrListColIndex = (int)VAL_ZERO;
|
||||
g_iCurrListColOrder = (int)VAL_ZERO;
|
||||
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_ECODE);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100);
|
||||
|
||||
// iColIndex++;
|
||||
// strColTitle.Empty();
|
||||
// strColTitle.LoadString(IDS_DB_GR_CSTATE);
|
||||
// GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 150);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_OMVALUE);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 90);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_OMSTATUS);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 150);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_OM1VALUE);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 90);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_OM1STATUS);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 150);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_MDATE);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_GR_MTIME);
|
||||
GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 110);
|
||||
|
||||
|
||||
}
|
||||
|
||||
BOOL CAppDataTdGrListView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
cs.style &= ~LVS_TYPEMASK;
|
||||
cs.style |= LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
|
||||
|
||||
return CListView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
void CAppDataTdGrListView::OnCustomDrawList(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
//NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
|
||||
LPNMLVCUSTOMDRAW pLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
|
||||
|
||||
*pResult = CDRF_DODEFAULT;
|
||||
|
||||
if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
|
||||
{
|
||||
*pResult = CDRF_NOTIFYITEMDRAW;
|
||||
}
|
||||
else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
|
||||
{
|
||||
*pResult = CDRF_NOTIFYSUBITEMDRAW;
|
||||
}
|
||||
else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
|
||||
{
|
||||
if (pLVCD->iSubItem == 2 || pLVCD->iSubItem == 4)
|
||||
{
|
||||
CString strStatus;
|
||||
strStatus = GetListCtrl().GetItemText(pLVCD->nmcd.dwItemSpec, 2);
|
||||
if (strcmp(strStatus, _T("短路")) == 0
|
||||
|| strcmp(strStatus, _T("Short circuit")) == 0
|
||||
|| strcmp(strStatus, _T("开路")) == 0
|
||||
|| strcmp(strStatus, _T("Open circuit")) == 0)
|
||||
{
|
||||
pLVCD->clrText = RGB(255, 0, 0);
|
||||
}
|
||||
else if (strcmp(strStatus, _T("大电阻")) == 0
|
||||
|| strcmp(strStatus, _T("Too large")) == 0)
|
||||
{
|
||||
pLVCD->clrText = RGB(0, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
pLVCD->clrText = RGB(0, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pLVCD->clrText = RGB(0,0,0);
|
||||
}
|
||||
*pResult = CDRF_DODEFAULT;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user