⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odbcsampleview.cpp

📁 这源代码是书本《visual c++.net MFC 类库应用详解》的
💻 CPP
字号:
// OdbcSampleView.cpp : COdbcSampleView 类的实现
//

#include "stdafx.h"
#include "OdbcSample.h"

#include "OdbcSampleSet.h"
#include "OdbcSampleDoc.h"
#include "OdbcSampleView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// COdbcSampleView

IMPLEMENT_DYNCREATE(COdbcSampleView, CRecordView)

BEGIN_MESSAGE_MAP(COdbcSampleView, CRecordView)
	// 标准打印命令
	ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

// COdbcSampleView 构造/销毁

COdbcSampleView::COdbcSampleView()
	: CRecordView(COdbcSampleView::IDD)
{
	m_pSet = NULL;
	// TODO: 在此处添加构造代码

}

COdbcSampleView::~COdbcSampleView()
{
}

void COdbcSampleView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	// 可以在此处插入 DDX_Field* 函数以将控件“连接”到数据库字段,例如
	DDX_FieldText(pDX, IDC_NUMBER, m_pSet->m_Number, m_pSet);
	DDX_FieldText(pDX, IDC_BOOKNUM, m_pSet->m_BookNum, m_pSet);
	DDX_FieldText(pDX, IDC_BOOKNAME, m_pSet->m_BookName, m_pSet);
	DDX_FieldText(pDX, IDC_AUTHOR, m_pSet->m_Author, m_pSet);
	DDX_FieldText(pDX, IDC_PUBLISHER, m_pSet->m_Publisher, m_pSet);
	DDX_FieldText(pDX, IDC_PUBLISHSITE, m_pSet->m_PublishSite, m_pSet);
	DDX_FieldText(pDX, IDC_YEAR, m_pSet->m_Year, m_pSet);
	DDX_FieldText(pDX, IDC_MONTH, m_pSet->m_Month, m_pSet);
	DDX_FieldText(pDX, IDC_PRICE, m_pSet->m_Price, m_pSet);
	// 有关更多信息,请参阅 MSDN 和 ODBC 示例
}

BOOL COdbcSampleView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
	// 样式

	return CRecordView::PreCreateWindow(cs);
}

void COdbcSampleView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_OdbcSampleSet;
	CRecordView::OnInitialUpdate();
}


// COdbcSampleView 打印

BOOL COdbcSampleView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void COdbcSampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印前添加额外的初始化
}

void COdbcSampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印后添加清除过程
}


// COdbcSampleView 诊断

#ifdef _DEBUG
void COdbcSampleView::AssertValid() const
{
	CRecordView::AssertValid();
}

void COdbcSampleView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

COdbcSampleDoc* COdbcSampleView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COdbcSampleDoc)));
	return (COdbcSampleDoc*)m_pDocument;
}
#endif //_DEBUG


// COdbcSampleView 数据库支持
CRecordset* COdbcSampleView::OnGetRecordset()
{
	return m_pSet;
}



// COdbcSampleView 消息处理程序

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -