📄 datareceivedlg.cpp
字号:
// DataReceiveDlg.cpp : implementation file
//
#include "stdafx.h"
#include "串口通信.h"
#include "DataReceiveDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDataReceiveDlg dialog
CDataReceiveDlg::CDataReceiveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDataReceiveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDataReceiveDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDataReceiveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDataReceiveDlg)
DDX_Control(pDX, IDC_LIST1, m_List);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDataReceiveDlg, CDialog)
//{{AFX_MSG_MAP(CDataReceiveDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDataReceiveDlg message handlers
BOOL CDataReceiveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
this->m_pRS=new CDaoRecordset(&m_db);
ListView_SetExtendedListViewStyle( m_List.m_hWnd,
LVS_EX_FULLROWSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_UNDERLINEHOT );
m_List.InsertColumn(0,"时间",NULL,200);
m_List.InsertColumn(1,"数据",NULL,300);
this->OpenTable();
this->m_pRS->Close();
this->m_db.Close();
return TRUE;
}
void CDataReceiveDlg::OpenTable()
{
int nItem;
COleVariant var;
var.ChangeType(VT_BSTR,NULL);
this->m_db.Open("temp.mdb");
this->m_pRS->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from Receive",NULL);
while(!this->m_pRS->IsEOF())
{
nItem=this->m_List.InsertItem(this->m_List.GetItemCount()+1,NULL);
this->m_pRS->GetFieldValue("时间",var);
this->m_List.SetItemText(nItem,0,(LPCSTR)var.pbstrVal);
this->m_pRS->GetFieldValue("数据",var);
this->m_List.SetItemText(nItem,1,(LPCSTR)var.pbstrVal);
this->m_pRS->MoveNext();
}
}
BOOL CDataReceiveDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
delete this->m_pRS;
return CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -