📄 sendstudentview.cpp
字号:
// SendStudentView.cpp : implementation of the CSendStudentView class
//
#include "stdafx.h"
#include "SendStudent.h"
#include "SendStudentSet.h"
#include "SendStudentDoc.h"
#include "SendStudentView.h"
#include "KrrCom.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSendStudentView
IMPLEMENT_DYNCREATE(CSendStudentView, CRecordView)
BEGIN_MESSAGE_MAP(CSendStudentView, CRecordView)
//{{AFX_MSG_MAP(CSendStudentView)
ON_BN_CLICKED(IDC_BT_SEND_TO_COM1, OnBtSendToCom1)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSendStudentView construction/destruction
CSendStudentView::CSendStudentView()
: CRecordView(CSendStudentView::IDD)
{
//{{AFX_DATA_INIT(CSendStudentView)
m_pSet = NULL;
m_nID = 0;
m_strName = _T("");
m_strPhone = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CSendStudentView::~CSendStudentView()
{
}
void CSendStudentView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSendStudentView)
DDX_Text(pDX, IDC_EDIT_ID, m_nID);
DDV_MinMaxLong(pDX, m_nID, 0, 65535);
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
DDV_MaxChars(pDX, m_strName, 19);
DDX_Text(pDX, IDC_EDIT_PHONE, m_strPhone);
DDV_MaxChars(pDX, m_strPhone, 19);
//}}AFX_DATA_MAP
}
BOOL CSendStudentView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CSendStudentView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_sendStudentSet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_com.Open ("COM1:");
m_pSet->MoveFirst();
m_nID=m_pSet->m_StudentID;
m_strName=m_pSet->m_StudentName;
m_strPhone=m_pSet->m_Telephone;
UpdateData(FALSE);
}
/////////////////////////////////////////////////////////////////////////////
// CSendStudentView diagnostics
#ifdef _DEBUG
void CSendStudentView::AssertValid() const
{
CRecordView::AssertValid();
}
void CSendStudentView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CSendStudentDoc* CSendStudentView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSendStudentDoc)));
return (CSendStudentDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSendStudentView database support
CRecordset* CSendStudentView::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CSendStudentView message handlers
BOOL CSendStudentView::OnMove(UINT nIDMoveCommand)
{
// TODO: Add your specialized code here and/or call the base class
if (CRecordView::OnMove(nIDMoveCommand)){
m_nID = m_pSet->m_StudentID;
m_strName = m_pSet->m_StudentName;
m_strPhone = m_pSet->m_Telephone;
UpdateData (FALSE);
return TRUE;
}
else{
return FALSE;
}
return FALSE;
}
void CSendStudentView::OnBtSendToCom1()
{
m_com.Write ((BYTE*)&m_nID,sizeof(m_nID));
BYTE buf[20] = {0};
strcpy ((char*)buf, m_strName.GetBuffer(m_strName.GetLength()));
m_com.Write (buf,sizeof(buf));
strcpy ((char*)buf, m_strPhone.GetBuffer(m_strPhone.GetLength()));
m_com.Write (buf,sizeof(buf));
}
void CSendStudentView::OnDestroy()
{
CRecordView::OnDestroy();
m_com.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -