The MFC CRecordView Class

The CRecordView class is a form view class that's attached to a recordset. Figure 31-4 illustrates an MFC record view application. The toolbar buttons enable the user to step forward and backward through a database table.

Figure 31-4. An MFC application based on the CRecordView class.

Like the CFormView class, the CRecordView class depends on a dialog template resource. The CFormView class has data members that correspond to the controls in the dialog box, but the CRecordView class accesses data members in a foreign object, namely the attached CRecordset object. When the user enters data in the controls, the record view's DDX (Dialog Data Exchange) code moves the data into the recordset's data members, which are bound to database columns by the recordset's RFX (Record Field Exchange) code.

When you specify a database view application, AppWizard generates a class derived from CRecordView together with an empty dialog template. AppWizard also generates a class derived from CRecordset, so it must ask you for a database table name. At runtime, the record view object and the recordset object are connected. Your job is to add controls to the dialog template and match the controls to recordset data members—no C++ programming is required to create a working form-based database application.

AppWizard generates a read-only, view-based database application. If you want to modify, add, and delete records, you must do some coding. The default behavior of the resulting application matches the behavior of Visual Basic and Access, which is a little weird. A record is added or modified only when the user moves out of it. If that's what you want, you can pattern your applications after the ENROLL sample program in the \ \Samples\VC98\Mfc\Tutorial\Enroll directory on the Visual C++ MSDN CD-ROM.



Programming Visual C++
Advanced 3ds max 5 Modeling & Animating
ISBN: 1572318570
EAN: 2147483647
Year: 1997
Pages: 331
Authors: Boris Kulagin

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net