Along with the classes, AppWizard creates a dialog template resource named IDD_ENROLL_FORM
, which the CRecordView-derived class, CSectionForm
, uses to display its form controls. Because CRecordView is derived from CFormView, a record view’s client area is laid out by a dialog template resource. The layout of the form is up to you. AppWizard places one static text control on the dialog template resource, labeled “TODO: Place form controls on this dialog.”
In the following procedure, you will replace this text with controls that correspond to columns in the table (via the field data members of the recordset). The table below lists the columns and their associated edit control IDs and variable names.
Enroll's Controls and Member Variables
Column name | Control ID | Variable Name |
Course | IDC_COURSE |
|
Section | IDC_SECTION |
|
Instructor | IDC_INSTRUCTOR |
|
Room | IDC_ROOM |
|
Schedule | IDC_SCHEDULE |
|
Capacity | IDC_CAPACITY |
|
To customize Enroll’s form
IDD_ENROLL_FORM
.The dialog editor opens and displays the dialog box with the corresponding ID.
TODO: Place form controls on this dialog
. Tip You can press CTRL before you click a dialog box control; then release the CTRL key and click in the dialog box multiple times to add multiple copies of the control. For instance, if you want six edit controls, click six times. Click the selection arrow to stop adding controls.
Resize the dialog box as needed. You can either add the controls in pairs (that is, first a static text control and then the corresponding edit control, and so on) or later change the Tab order of the controls, as described at the end of this topic, so that they are paired in this way. This becomes important when you bind the controls to recordset fields, described in the next topic.
IDC_COURSE
). This is only a convention, but it is used throughout the tutorial.Note The “Edit” caption that appears in each edit control is not visible to the user at run time, so you needn’t worry about deleting it. To view the dialog as it will appear at run time, press CTRL+T to enter test mode for the dialog box. Press ESC to cancel test mode.
The Layout of Enroll’s Section Form
According to a common rule in the user-interface design of database forms, the user shouldn’t be able to update these key fields. If users want to change a course number or section of a Section record, they must delete the old Section record and add a new one to avoid possibly violating the referential integrity of the database. Enroll tutorial Step 3 implements Add and Delete functionality.
It’s a good idea to periodically back up your work.
If you did not add the static text and corresponding edit controls in order, one after the other, you need to change the tab order. In either case, you can easily check the current tab order and change it if necessary.
To view or change the tab order of controls
You’ll see numbers depicting the current tab order of the controls.
As you click, you’ll see the numbering change to reflect your choice.
For Enroll, specify a tab order such that each edit control is preceded in the tab order by the static text control that describes it. By specifying this tab order, you enable ClassWizard to derive a name for the edit control when you bind it to a data member, as you’ll do in the next section.
Leave the dialog editor open for the next procedure.