使用CRecordview并没有任何反应 [英] using the CRecordview and nothing happens

查看:148
本文介绍了使用CRecordview并没有任何反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于CRecordview的视图上的控件不起作用.我尝试使用列表控件并发送AddString().但是运行程序时什么也没发生.有人可以帮我解释一下吗?当您创建从CRecordView派生的类型的对象时,请调用两种形式的构造函数以初始化视图对象并标识视图所基于的对话框资源.您可以通过名称(将字符串作为构造函数的参数传递)或通过其ID(通过无符号整数作为参数)标识资源.建议使用资源ID.
注意您的派生类必须提供自己的构造函数.在派生类的构造函数中,使用资源名称或ID作为参数调用构造函数CRecordView :: CRecordView,如下例所示.
CRecordView :: OnInitialUpdate调用UpdateData,后者调用DoDataExchange.最初对DoDataExchange的调用将CRecordView控件(间接)连接到ClassWizard创建的CRecordset字段数据成员.在调用基类CFormView :: OnInitialUpdate成员函数之后,才能使用这些数据成员.
注意如果使用ClassWizard,向导将定义一个枚举值CRecordView :: IDD并在构造函数的成员初始化列表中指定该值,在示例中您会看到IDD_MYFORM.该示例显示了如果没有向导就自己编写代码,那么如何指定对话框模板资源ID.
例子
CMyRecordView :: CMyRecordView()
:CRecordView(IDD_MYFORM)
{
//{{AFX_DATA_INIT(CMyRecordView)
//注意:ClassWizard将在此处添加成员初始化
//}} AFX_DATA_INIT
//其他构造代码,例如数据初始化
}


The controls on the CRecordview based views doesn''t work.I tried by using a list control and sending the AddString().But nothing happens when I run the progam.Can anybody explain this stuff for me?.

解决方案

When you create an object of a type derived from CRecordView, call either form of the constructor to initialize the view object and identify the dialog resource on which the view is based. You can either identify the resource by name (pass a string as the argument to the constructor) or by its ID (pass an unsigned integer as the argument). Using a resource ID is recommended.
Note Your derived class must supply its own constructor. In the constructor of your derived class, call the constructor CRecordView::CRecordView with the resource name or ID as an argument, as shown in the example below.
CRecordView::OnInitialUpdate calls UpdateData, which calls DoDataExchange. This initial call to DoDataExchange connects CRecordView controls (indirectly) to CRecordset field data members created by ClassWizard. These data members cannot be used until after you call the base class CFormView::OnInitialUpdate member function.
Note If you use ClassWizard, the wizard defines an enum value CRecordView::IDD and specifies it in the member initialization list for the constructor where you see IDD_MYFORM in the example. The example shows how you can specify the dialog template resource ID if you write the code yourself without the wizard.
Example
CMyRecordView::CMyRecordView()
: CRecordView( IDD_MYFORM )
{
//{{AFX_DATA_INIT( CMyRecordView )
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Other construction code, such as data initialization
}


这篇关于使用CRecordview并没有任何反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆