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
-
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.
-
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.
-
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.
-
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
-
In Visual Modeler, open the Browser window by clicking Browser on the View menu.
-
Expand the Component View by clicking the + icon to the left of the Component View folder icon.
-
Right-click the <<EXE>> Enroll node and click Generate Code from the popup menu.
-
In the Open Microsoft Visual C++ Project dialog box, navigate to and select the Enroll.dsw project.
-
The Code Generation - Summary dialog box appears. Examine the Summary and Log tabs for information regarding the code generation.
-
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.
-
(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.
-
Build the sample by clicking Build enroll.exe from the Build menu.
-
Run the sample by clicking Execute enroll.exe from the Build menu.