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

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

// CDialogSysRec 对话框

IMPLEMENT_DYNAMIC(CDialogSysRec, CDialogEx)

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

}

CDialogSysRec::~CDialogSysRec()
{
}

void CDialogSysRec::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST_SYS_REC_INFO, m_CListCtrlInfo);
}


BOOL CDialogSysRec::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_CListCtrlInfo.GetClientRect(&rect);

	m_CListCtrlInfo.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
	//m_listsal.SetBkColor(RGB(208,224,240));
	m_CListCtrlInfo.SetBkColor(RGB(240, 240, 240));
	m_CListCtrlInfo.SetTextBkColor(RGB(240, 240, 240));
	m_CListCtrlInfo.InsertColumn(0, _T("信息"), LVCFMT_CENTER, (rect.Width() * 5) / 10, -1);
	m_CListCtrlInfo.InsertColumn(1, _T("时间"), LVCFMT_CENTER, (rect.Width() * 5) / 10, -1);
	m_CListCtrlInfo.SetFont(&font);
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->wndSaveSys = this;
	((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->Get_Sys(REC_CURRENT);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE

}

BEGIN_MESSAGE_MAP(CDialogSysRec, CDialogEx)
	ON_WM_DESTROY()
	ON_MESSAGE(WM_MONITOR_STATUS, OnMonitorStatus)
	ON_BN_CLICKED(IDC_BUTTON_SYS_REC_PRE, &CDialogSysRec::OnBnClickedButtonSysRecPre)
	ON_BN_CLICKED(IDC_BUTTON_SYS_REC_NEXT, &CDialogSysRec::OnBnClickedButtonSysRecNext)
	ON_BN_CLICKED(IDOK, &CDialogSysRec::OnBnClickedOk)
END_MESSAGE_MAP()


// CDialogSysRec 消息处理程序


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

		break;
	}

	return 0;
}

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

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


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

	m_CListCtrlInfo.DeleteAllItems();
	for (list<struct SYS_DATA>::iterator iter = ((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->m_stlGetSys.begin(); iter != ((CThreadDataAlmRec *)(theApp.m_pThrdDataSave))->m_stlGetSys.end(); iter++)
	{
		m_CListCtrlInfo.InsertItem(i, _T(""));
		m_CListCtrlInfo.SetItemText(i, 0, iter->cInfo);
		m_CListCtrlInfo.SetItemText(i, 1, iter->cTime);
		
		i++;
	}

}


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


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


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