CRecordView
2025-12-24
Written by: xiaobin
Use the CFormView template, and then manually rewrite it as CRecordView.
CObject
CCmdTarget
CWnd
CView
CScrollView
CFormView
CRecordView
NOTE!!! The database wizard is no longer provided in VS2017 and later versions.
(Figure: Step 6 of the MFC Application Wizard in Visual Studio 2013)
Implement database support in CRecordView.
// CMFCApplication1View database support
CRecordset* CMFCApplication1View::OnGetRecordset()
{
return m_pSet;
}
// Overrides
public:
virtual CRecordset* OnGetRecordset();
A document is a collection of data in your application with which the user interacts.
Although the word document seems to imply something of a textual nature, it isn’t limited to text. It could be data for a game, a geometric model, a text file, or, indeed, anything you want.
The term document is just a convenient label for the application data in your program, treated as a unit.
// Attributes
public:
CRec1Set m_Rec1Set;
you add your own data members to store items that your application requires.
Initialization is performed in “MFCApplication1View.cpp”.
// TODO: add construction code here
m_pSet = nullptr;
public:
#ifdef AFX_DESIGN_TIME
enum{ IDD = IDD_MFCAPPLICATION1_FORM };
#endif
CRec1Set* m_pSet;
at “MFCApplication1View.h”
uses dashed arrows to show how pointers are used to relate objects. These pointers
enable function members of one object to access the public data or function members in the interface of another object.
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_pSet = &GetDocument()->m_Rec1Set;
CRecordView::OnInitialUpdate();
member functions(GetDocument()) to support processing of that data.