📄 sample04view.cpp
字号:
// Sample04View.cpp : implementation of the CSample04View class
//
#include "stdafx.h"
#include "Sample04.h"
#include "Sample04Set.h"
#include "Sample04Doc.h"
#include "Sample04View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSample04View
IMPLEMENT_DYNCREATE(CSample04View, COleDBRecordView)
BEGIN_MESSAGE_MAP(CSample04View, COleDBRecordView)
//{{AFX_MSG_MAP(CSample04View)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, COleDBRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, COleDBRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, COleDBRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample04View construction/destruction
CSample04View::CSample04View()
: COleDBRecordView(CSample04View::IDD)
{
//{{AFX_DATA_INIT(CSample04View)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CSample04View::~CSample04View()
{
}
void CSample04View::DoDataExchange(CDataExchange* pDX)
{
COleDBRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSample04View)
DDX_Text(pDX, IDC_ID, m_pSet->m_ID);
DDX_Text(pDX, IDC_NAME, CString(m_pSet->m_column0));
DDX_Text(pDX, IDC_DEPT, CString(m_pSet->m_column1));
DDX_Text(pDX, IDC_PHONE, CString(m_pSet->m_column2));
DDX_Text(pDX, IDC_EMAIL, CString(m_pSet->m_E_mail));
DDX_Text(pDX, IDC_REMARK, CString(m_pSet->m_column3));
//}}AFX_DATA_MAP
}
BOOL CSample04View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return COleDBRecordView::PreCreateWindow(cs);
}
void CSample04View::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_Sample04Set;
{
CWaitCursor wait;
HRESULT hr = m_pSet->Open();
if (hr != S_OK)
{
AfxMessageBox(_T("Record set failed to open."), MB_OK);
// Disable the Next and Previous record commands,
// since attempting to change the current record without an
// open RecordSet will cause a crash.
m_bOnFirstRecord = TRUE;
m_bOnLastRecord = TRUE;
}
}
COleDBRecordView::OnInitialUpdate();
}
/////////////////////////////////////////////////////////////////////////////
// CSample04View printing
BOOL CSample04View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CSample04View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CSample04View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CSample04View diagnostics
#ifdef _DEBUG
void CSample04View::AssertValid() const
{
COleDBRecordView::AssertValid();
}
void CSample04View::Dump(CDumpContext& dc) const
{
COleDBRecordView::Dump(dc);
}
CSample04Doc* CSample04View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSample04Doc)));
return (CSample04Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSample04View database support
CRowset* CSample04View::OnGetRowset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CSample04View message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -