一个在vs2005+上创建一个基于CRecordView的对话框

在vs2005+之上 好像基类没有CRecordView类,要想建立一个基于CRecordView的类,我暂时没有找到好的方法,只能手动添加了。。。

这里的SSS是你要创建的类的名字;

#if !defined(AFX_SSS_H__4F498E08_A53F_46D5_B438_AD50C0E3A6F1__INCLUDED_)

#define AFX_SSS_H__4F498E08_A53F_46D5_B438_AD50C0E3A6F1__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SSS.h : header file
//


/
// SSS record view   SSS就是你要创建的dialog对话框的名字


#include "SysUserSet.h   //SysUserSet是关联了dialog所关联的数据库的类。


class SSS : public CRecordView
{
protected:
SSS();           // protected constructor used by dynamic creation
DECLARE_DYNCREATE(SSS)


// Form Data
public:
//{{AFX_DATA(SSS)
enum { IDD = IDD_SYS };//此处应为dialgog的IDD
CSysUserSet* m_pSet; 
//}}AFX_DATA


// Attributes
public:


// Operations
public:
CSysUserSet* GetRecordset();




// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(SSS)
// NOTE - the ClassWizard will add and remove member functions here.
public:
virtual CRecordset* OnGetRecordset();
protected:
virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
virtual void OnInitialUpdate();
//}}AFX_VIRTUAL


// Implementation
protected:
virtual ~SSS();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif


// Generated message map functions
//{{AFX_MSG(SSS)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};


/


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.


#endif // !defined(AFX_SSS_H__4F498E08_A53F_46D5_B438_AD50C0E3A6F1__INCLUDED_)

// SSS.cpp : implementation file
//


#include "stdafx.h"
#include "TestApp.h"
#include "SSS.h"


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


/
// SSS


IMPLEMENT_DYNCREATE(SSS, CRecordView)


SSS::SSS()
: CRecordView(SSS::IDD)
{
//{{AFX_DATA_INIT(SSS)
m_pSet = NULL;
//}}AFX_DATA_INIT
}


SSS::~SSS()
{
if (m_pSet)
delete m_pSet;
}


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




BEGIN_MESSAGE_MAP(SSS, CRecordView)
//{{AFX_MSG_MAP(SSS)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/
// SSS diagnostics


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


void SSS::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
#endif //_DEBUG


/
// SSS message handlers


CRecordset* SSS::OnGetRecordset()
{
if (m_pSet != NULL)
return m_pSet;


m_pSet = new CSysUserSet(NULL);
m_pSet->Open();


return m_pSet;
}


CSysUserSet* SSS::GetRecordset()
{
CSysUserSet* pData = (CSysUserSet*) OnGetRecordset();
ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(CSysUserSet)));
return pData;
}


void SSS::OnInitialUpdate()
{
BeginWaitCursor();
GetRecordset();
CRecordView::OnInitialUpdate();
if (m_pSet->IsOpen())
{
CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();
CString strTable = m_pSet->GetTableName();
if (!strTable.IsEmpty())
strTitle += _T(":") + strTable;
GetDocument()->SetTitle(strTitle);
}
EndWaitCursor();
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值