Changing the Sample Visually

Updating the Model

In the previous exercise, you browsed the specification of the ECourse class. Now, suppose that you want to add a new integer property to the ECourse class, named m_Credits, to represents the number of credits each course grants upon completion.

To change the properties of the ECourse class

  1. As in the previous exercise, double-click the ECourse class in the Business Services pane. This displays the Class Specification for ECourse. Click the Properties tab to view the member variables of the class.

  2. Use the right mouse button to click inside the list of properties. Click Insert from the popup menu. Type m_Credits for the property name and press Enter.

  3. Double-click with the left mouse button in the Type column of m_Credits. The Property Specification for m_Credits appears. Assign a type of int and an Initial value of 0.

  4. Click OK on the Property Specification and Class Specification to save your changes.

Generating C++ Code

Up to this point in the tutorial, no C++ code has been generated from the Visual Modeler.

To generate code for the changed ECourse class

  1. In Visual Modeler, open the Browser window by clicking Browser on the View menu.

  2. Expand the Component View by clicking the + icon to the left of the Component View folder icon.

  3. Right-click the <<EXE>> Enroll node and click Generate Code from the popup menu.

  4. In the Open Microsoft Visual C++ Project dialog box, navigate to and select the Enroll.dsw project.

  5. The Code Generation - Summary dialog box appears. Examine the Summary and Log tabs for information regarding the code generation.

  6. Open ECourse.h in the Visual C++ project window to view the C++ class declaration for ECourse with the new m_Credits integer member variable.

  7. (Optional) To add the credit field to the form, edit the IDD_COURSE_FORM resource in the Enroll.rc resource file. To persist the new m_Credits variable in the database, add a column for that variable in the Course table of StdReg32.mdb.

  8. Build the sample by clicking Build enroll.exe from the Build menu.

  9. Run the sample by clicking Execute enroll.exe from the Build menu.