// DialogNIBPRec.cpp : 实现文件
//

#include "stdafx.h"
#include "Verbpo.h"
#include "DialogNIBPRec.h"
#include "afxdialogex.h"
#include "ThreadDataAlmRec.h"

// CDialogNIBPRec 对话框

IMPLEMENT_DYNAMIC(CDialogNIBPRec, CDialogEx)

CDialogNIBPRec::CDialogNIBPRec(CWnd* pParent /*=NULL*/)
	: CDialogEx(CDialogNIBPRec::IDD, pParent)
{

}

CDialogNIBPRec::~CDialogNIBPRec()
{
}

void CDialogNIBPRec::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST_NIBP_REC_RESULT, m_CListCtrlNIBPResult);
}

BOOL CDialogNIBPRec::OnInitDialog()
{
	CRect rect;
	CString a_cs;
	CDialogEx::OnInitDialog();
	
	font.CreateFont(20,                                          //   nHeight     
		0,                                                   //   nWidth     
		0,                                                   //   nEscapement   
		0,                                                   //   nOrientation     
		FW_NORMAL,                                   //   nWeight     
		TRUE,                                           //   bItalic     
		FALSE,                                           //   bUnderline     
		0,                                                   //   cStrikeOut     
		ANSI_CHARSET,                             //   nCharSet     
		OUT_DEFAULT_PRECIS,                 //   nOutPrecision     
		CLIP_DEFAULT_PRECIS,               //   nClipPrecision     
		DEFAULT_QUALITY,                       //   nQuality     
		DEFAULT_PITCH | FF_SWISS,     //   nPitchAndFamily       
		_T("宋体"));

	m_CListCtrlNIBPResult.GetClientRect(&rect);

	m_CListCtrlNIBPResult.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
	//m_listsal.SetBkColor(RGB(208,224,240));
	m_CListCtrlNIBPResult.SetBkColor(RGB(240, 240, 240));
	m_CListCtrlNIBPResult.SetTextBkColor(RGB(240, 240, 240));
	m_CListCtrlNIBPResult.InsertColumn(0, _T("收缩压"), LVCFMT_CENTER, (rect.Width() * 3) / 20, -1);
	m_CListCtrlNIBPResult.InsertColumn(1, _T("舒张压"), LVCFMT_CENTER, (rect.Width() * 3) / 20, -1);
	m_CListCtrlNIBPResult.InsertColumn(2, _T("平均压"), LVCFMT_CENTER, (rect.Width() * 3) / 20, -1);
	m_CListCtrlNIBPResult.InsertColumn(3, _T("测量时间"), LVCFMT_CENTER, (rect.Width() * 11) / 20, -1);
	m_CListCtrlNIBPResult.SetFont(&font);
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->wndSaveNIBP = this;
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->Get_NIBP(REC_CURRENT);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE

}


BEGIN_MESSAGE_MAP(CDialogNIBPRec, CDialogEx)
	ON_WM_DESTROY()
	ON_MESSAGE(WM_MONITOR_STATUS, OnMonitorStatus)
	ON_BN_CLICKED(IDOK, &CDialogNIBPRec::OnBnClickedOk)
	ON_BN_CLICKED(IDC_BUTTON_NIBP_REC_PRE, &CDialogNIBPRec::OnBnClickedButtonNibpRecPre)
	ON_BN_CLICKED(IDC_BUTTON_NIBP_REC_NEXT, &CDialogNIBPRec::OnBnClickedButtonNibpRecNext)
END_MESSAGE_MAP()


// CDialogNIBPRec 消息处理程序

void CDialogNIBPRec::OnDestroy()
{
	CDialogEx::OnDestroy();

	// TODO:  在此处添加消息处理程序代码
	font.DeleteObject();
}



LRESULT  CDialogNIBPRec::OnMonitorStatus(WPARAM wPara, LPARAM lPara)
{
	switch (wPara)
	{
	case WM_REC_GET_OK:
		Show_Result();
		
		break;
	}

	return 0;
}



void CDialogNIBPRec::Show_Result()
{
	CString a_cs;
	INT i = 0;

	m_CListCtrlNIBPResult.DeleteAllItems();
	for (list<struct NIBP_DATA>::iterator iter = ((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->m_stlGetNIBP.begin(); iter != ((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->m_stlGetNIBP.end(); iter++)
	{
		m_CListCtrlNIBPResult.InsertItem(i, _T(""));
		a_cs.Format(_T("%d"), iter->i16SBP);
		m_CListCtrlNIBPResult.SetItemText(i, 0, a_cs);
		a_cs.Format(_T("%d"), iter->i16DBP);
		m_CListCtrlNIBPResult.SetItemText(i, 1, a_cs);
		a_cs.Format(_T("%d"), iter->i16MBP);
		m_CListCtrlNIBPResult.SetItemText(i, 2, a_cs);
		m_CListCtrlNIBPResult.SetItemText(i, 3, iter->cTime);
		i++;
	}

}



void CDialogNIBPRec::OnBnClickedOk()
{
	// TODO:  在此添加控件通知处理程序代码
	CDialogEx::OnOK();
}



void CDialogNIBPRec::OnBnClickedButtonNibpRecPre()
{
	// TODO:  在此添加控件通知处理程序代码
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->wndSaveNIBP = this;
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->Get_NIBP(REC_BACKWARD);
}



void CDialogNIBPRec::OnBnClickedButtonNibpRecNext()
{
	// TODO:  在此添加控件通知处理程序代码
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->wndSaveNIBP = this;
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->Get_NIBP(REC_FORWARD);
}
