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

📄 myoledbview.cpp

📁 拥有检测数据库是否连接成功的功能,以及第一个记录,前一个记录,下一个记录,以及最后一个的记录的检测以及显示功能.适合初学者.
💻 CPP
字号:
// MyOleDBView.cpp : implementation of the CMyOleDBView class
//

#include "stdafx.h"
#include "MyOleDB.h"

#include "MyOleDBSet.h"
#include "MyOleDBDoc.h"
#include "MyOleDBView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView

IMPLEMENT_DYNCREATE(CMyOleDBView, COleDBRecordView)

BEGIN_MESSAGE_MAP(CMyOleDBView, COleDBRecordView)
	//{{AFX_MSG_MAP(CMyOleDBView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView construction/destruction

CMyOleDBView::CMyOleDBView()
	: COleDBRecordView(CMyOleDBView::IDD)
{
	//{{AFX_DATA_INIT(CMyOleDBView)
		// NOTE: the ClassWizard will add member initialization here
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CMyOleDBView::~CMyOleDBView()
{
}

void CMyOleDBView::DoDataExchange(CDataExchange* pDX)
{
	COleDBRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyOleDBView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BOOL CMyOleDBView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return COleDBRecordView::PreCreateWindow(cs);
}

void CMyOleDBView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_myOleDBSet;
	{
		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();

}

/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView printing

BOOL CMyOleDBView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyOleDBView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyOleDBView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView diagnostics

#ifdef _DEBUG
void CMyOleDBView::AssertValid() const
{
	COleDBRecordView::AssertValid();
}

void CMyOleDBView::Dump(CDumpContext& dc) const
{
	COleDBRecordView::Dump(dc);
}

CMyOleDBDoc* CMyOleDBView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyOleDBDoc)));
	return (CMyOleDBDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView database support
CRowset* CMyOleDBView::OnGetRowset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CMyOleDBView message handlers

⌨️ 快捷键说明

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