【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-Ex11_1View.cpp,希望本篇文章对您学习有所帮助。
// Ex11_1View.cpp : implementation of the CEx11_1View class
//
#include "stdafx.h"
#include "Ex11_1.h"
#include "Ex11_1Set.h"
#include "Ex11_1Doc.h"
#include "Ex11_1View.h"
#include "FilterDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View
IMPLEMENT_DYNCREATE(CEx11_1View, CRecordView)
BEGIN_MESSAGE_MAP(CEx11_1View, CRecordView)
//{{AFX_MSG_MAP(CEx11_1View)
ON_COMMAND(ID_RECORD_ADD, OnRecordAdd)
ON_COMMAND(ID_RECORD_DELETE, OnRecordDelete)
ON_COMMAND(ID_SORT_STUID, OnSortStuid)
ON_COMMAND(ID_SORT_STUNAME, OnSortStuname)
ON_COMMAND(ID_SORT_STUNATIVEPLACE, OnSortStunativeplace)
ON_COMMAND(ID_SORT_STUCLASS, OnSortStuclass)
ON_COMMAND(ID_SORT_STUCOLLEGE, OnSortStucollege)
ON_COMMAND(ID_FILTER_STUID, OnFilterStuid)
ON_COMMAND(ID_FILTER_STUNAME, OnFilterStuname)
ON_COMMAND(ID_FILTER_STUNATIVEPLACE, OnFilterStunativeplace)
ON_COMMAND(ID_FILTER_STUCLASS, OnFilterStuclass)
ON_COMMAND(ID_FILTER_STUCOLLEGE, OnFilterStucollege)
//}}AFX_MSG_MAP
// Standard printing commands
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()
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View construction/destruction
CEx11_1View::CEx11_1View()
: CRecordView(CEx11_1View::IDD)
{
//{{AFX_DATA_INIT(CEx11_1View)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
m_bAdding=false;
}
CEx11_1View::~CEx11_1View()
{
}
void CEx11_1View::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx11_1View)
DDX_FieldText(pDX, IDC_STUID, m_pSet->m_StuID, m_pSet);
DDX_FieldText(pDX, IDC_STUNAME, m_pSet->m_StuName, m_pSet);
DDX_FieldText(pDX, IDC_STUNATIVEPLACE, m_pSet->m_StuNativePlace, m_pSet);
DDX_FieldText(pDX, IDC_STUCLASS, m_pSet->m_StuClass, m_pSet);
DDX_FieldText(pDX, IDC_STUCOLLEGE, m_pSet->m_StuCollege, m_pSet);
//}}AFX_DATA_MAP
}
BOOL CEx11_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CEx11_1View::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_ex11_1Set;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View printing
BOOL CEx11_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx11_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx11_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View diagnostics
#ifdef _DEBUG
void CEx11_1View::AssertValid() const
{
CRecordView::AssertValid();
}
void CEx11_1View::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CEx11_1Doc* CEx11_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx11_1Doc)));
return (CEx11_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View database support
CRecordset* CEx11_1View::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CEx11_1View message handlers
void CEx11_1View::OnRecordAdd() //添加记录
{
// TODO: Add your command handler code here
m_pSet->AddNew();//建立一个空记录
m_bAdding=true;
CEdit *pCtrl=(CEdit*)GetDlgItem(IDC_STUID);//取得编辑控件的指针
int result=pCtrl->SetReadOnly(false);//编辑框只读状态改为false
UpdateData(false);//显示新的空白记录
}
void CEx11_1View::OnRecordDelete() //删除记录
{
// TODO: Add your command handler code here
m