Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Along with the classes, AppWizard creates a dialog template resource named IDD_DAOENROL_FORM
, which the CDaoRecordView-derived class, CSectionForm
, uses to display its form controls. Because CDaoRecordView 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.”
Suggested Reading in the Visual C++ User’s Guide
In the following procedure, you’ll 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.
DaoEnrol'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 DaoEnrol’s form
In the ResourceView, double-click the DaoEnrol folder.
Expand the Dialog folder.
Double-click IDD_DAOENROL_FORM.
The dialog editor opens and displays the dialog box with the corresponding ID.
Select and then delete the static control that says “TODO: Place form controls on this dialog.”
Design DaoEnrol’s Section form to resemble the figure The Layout of DaoEnrol’s Section Form, using static controls and edit controls.
Tip Press ALT+ENTER to display the Properties window, and then pin it down so it stays open while you add and edit the dialog box controls.
Resize the dialog box as needed. You may want to add the controls in pairs, for example: static text control, then the corresponding edit control, and so on.
For each edit control, use the ID box in the Properties window to specify an ID based on the table column names (for example,
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 box as it will appear at run time, press CTRL+T to enter test mode for the dialog box. Press ESC to cancel test mode.
Make the Course and Section edit controls read-only. To do so, select the Styles tab in the Properties window and set the Read-only check box. (The other edit controls are updatable.)
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. DaoEnrol Step 3 implements Add and Delete functionality.
Save the DaoEnrol Resources (DaoEnrol.rc).
It’s a good idea to periodically back up your work.
The Layout of DaoEnrol’s Section Form
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. You can easily check the current tab order and change it if necessary.
To view or change the tab order of controls
With the dialog resource open, from the Layout menu click Tab Order.
You’ll see numbers depicting the current tab order of the controls.
Specify the tab order you want by clicking each control in that order.
As you click, you’ll see the numbering change to reflect your choices.
For DaoEnrol, 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 topic.