With the form designed, it’s time to indicate which edit controls map to which table columns — or, more precisely, which controls map to which recordset field data members. To perform this task, you use ClassWizard’s “foreign object” mechanism.
Normally, you use ClassWizard to bind controls in a dialog box or form to member variables of your CDialog- or CFormView-derived class. In the case of CDaoRecordView, though, you bind the form’s controls not to data members of the record view class but to data members of the recordset class associated with the record view.
Your CDaoRecordView-derived class — CSectionForm
in this case — has a data member called m_pSet
. You can view m_pSet
in the ClassView of CSectionForm
. This data member is a pointer to CSectionSet
, DaoEnrol’s recordset class. Recall that you viewed this recordset class in the Member Variables tab of ClassWizard (see the figure Table Columns Mapped to Recordset Data Members).
The control bindings go through m_pSet
to the corresponding field data members of CSectionSet
. For example, in the following procedure, you will bind the Course edit control to:
m_pSet->m_CourseID
To bind a form control to a recordset data member
ClassWizard’s Add Member Variable dialog box appears, with a proposed field name selected for you in the Member variable name box. ClassWizard chooses this name based on the caption of a static text control that falls previous to the edit control in the tab order. For example, for IDC_COURSE
, the control’s caption is “Course,” and the Member variable name box should display:
m_pSet->m_CourseID
It isn’t necessary to create mappings for the static text controls.
Note Using CTRL+double-click in the dialog editor is a ClassWizard shortcut for mapping form controls to members of the associated dialog box, form view, or record view class. Use it on a button to create a command handler function for the button. Use it on other controls to create a class member variable.
You can view the complete mappings for class CSectionForm
in the ClassWizard Member Variables tab. For example, where IDC_COURSE
appears in the Control IDs column, you’ll see ->m_CourseID
in the corresponding Member column.