⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datalistview.cpp

📁 串口调试助手的源代码
💻 CPP
字号:
// Written by JHCC, 1997

// DataListView.cpp : implementation file
//

#include "stdafx.h"
#include "JHHB.h"
#include "JHHBDoc.h"
#include "DataListView.h"
#include "Jhhbview.h"  // ljh add

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDataListView

IMPLEMENT_DYNCREATE(CDataListView, CFormView)

CDataListView::CDataListView()
	: CFormView(CDataListView::IDD)
{
	//{{AFX_DATA_INIT(CDataListView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_strCurDateFmt = _T("");
	m_bInited = FALSE;
}

CDataListView::~CDataListView()
{
}

void CDataListView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDataListView)
	DDX_Control(pDX, IDC_DATAVIEWLIST, m_dataViewList);
	DDX_Control(pDX, IDC_DATEBUTTON, m_dateButton);
	//}}AFX_DATA_MAP
}

CJHHBDoc*	CDataListView::GetDocument(void)
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CJHHBDoc)));
	return  (CJHHBDoc*)m_pDocument;
}

BEGIN_MESSAGE_MAP(CDataListView, CFormView)
	//{{AFX_MSG_MAP(CDataListView)
	ON_BN_CLICKED(IDC_DATEBUTTON, OnDatebutton)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_RADIO1, OnPH)
	ON_BN_CLICKED(IDC_RADIO2, OnCOD)
	ON_BN_CLICKED(IDC_RADIO3, OnFlow)
	ON_BN_CLICKED(IDC_RADIO4, OnNH4N)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDataListView diagnostics

#ifdef _DEBUG
void CDataListView::AssertValid() const
{
	CFormView::AssertValid();
}

void CDataListView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

void CDataListView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	CSize sizeTotal;
	sizeTotal.cx = 10;
	sizeTotal.cy = 10;
	SetScrollSizes(MM_TEXT, sizeTotal);
	
	m_dataViewList.Set(GetDocument()->m_bUseDao,
		GetDocument()->m_pDaoStationInfoSet,
		GetDocument()->m_pStationInfoSet,
		GetDocument()->m_pDaoHBDateDataSet,
		GetDocument()->m_pHBDateDataSet);

	m_dateButton.GetWindowText(m_strCurDateFmt);
	m_dateButton.SetWindowText(GetDocument()->m_curSpyTime.Format(m_strCurDateFmt));

	m_dataViewList.SetTextColor(RGB(0, 0, 0xFF));
	m_dataViewList.AddAllRecord();

	m_bInited = TRUE;

	GetParentFrame()->RecalcLayout();
	ResizeParentToFit(TRUE);
}

void CDataListView::OnDatebutton()
{
	GetDocument()->OnDataHistory();

	m_dateButton.SetWindowText(GetDocument()->m_curSpyTime.Format(m_strCurDateFmt));
}

void CDataListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	if (m_bInited == TRUE)
	{
		m_dateButton.SetWindowText(GetDocument()->m_curSpyTime.Format(m_strCurDateFmt));
		m_dataViewList.AddAllRecord();
	}
}

void CDataListView::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);
	if (m_bInited == FALSE)
		return;

	CRect	rtBounds(0, 0, cx, cy);

	CRect	rtDateButton;
	m_dateButton.GetWindowRect(&rtDateButton);

	m_dateButton.SetWindowPos(NULL, 
		rtBounds.left, rtBounds.top, 
		rtDateButton.Width(), rtDateButton.Height(),
		SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);

	rtBounds.top += rtDateButton.Height();
	m_dataViewList.SetWindowPos(NULL,
		rtBounds.left,
		rtBounds.top,
		rtBounds.Width(),
		rtBounds.Height(),
		SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
}

////////////////////////////////////////////////////////////
////// ljh start
void CDataListView::OnPH() 
{
	// TODO: Add your control notification handler code here
    AfxMessageBox(_T("选择PH"));
	bSelectPH = true;
	bSelectCOD = false;
	bSelectFLOW = false;
	bSelectNH4N = false;	
}

void CDataListView::OnCOD() 
{
	// TODO: Add your control notification handler code here
	AfxMessageBox(_T("选择COD"));
	bSelectPH = false;
	bSelectCOD = true;
	bSelectFLOW = false;
	bSelectNH4N = false;
}

void CDataListView::OnFlow() 
{
	// TODO: Add your control notification handler code here
	AfxMessageBox(_T("选择流量"));
	bSelectPH = false;
	bSelectCOD = false;
	bSelectFLOW = true;
	bSelectNH4N = false;
}

void CDataListView::OnNH4N() 
{
	// TODO: Add your control notification handler code here
	AfxMessageBox(_T("选择氨氮NH4-N"));
	bSelectPH = false;
	bSelectCOD = false;
	bSelectFLOW = false;
	bSelectNH4N = true;
}

////////////////////////////////////////////////////////////
////// ljh end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -