Page 499
You can reinherit a property or method that you have overridden by selecting the property (or method) and pressing the Reinherit button at the top of the property sheet (it is two buttons to the right of the + button). When you do this, the property (or method) will revert to its inherited value, and the diamond will revert from black to gray.
As an object-oriented programming environment, Power Objects allows you to override a method that has been inherited. You can see how this is accomplished by referring to MyForm and MyFirstClass. As you recall, MyFirstClass contains a pushbutton named btnClose, which has method code specified for the Click method.
When you added an instance of MyFirstClass to MyForm, that class instance inherited the Click method code. Let's see how you can override the processing that was specified in btnClose.
MSGBOX("Override the Click method")
Figure 18.16. Page 500
Testing the overridden
method.
Power Objects will also permit you to override the method code and invoke the inherited method code. The statement Inherited.Method_name() is used to execute the default processing for a method. Using the example of MyForm and MyFirstClass, suppose that you have decided that you want to display a message box when Close is clicked but also want the inherited method code to execute. To achieve this, select btnClose on MyForm, and right-click Property Sheet. Scroll down to the Click method, and enter these two lines of Oracle Basic:
MSGBOX("Override the Click method") Inherited.Click()
The first line will display a message box containing the specified message. The second line will invoke the method code for btnClose that specified in the class, MyFirstClass. Exit the property sheet, and test the form. When you click on Close, the message box displays the message about overriding the Click method. When you click OK, another message box appears, demonstrating that the inherited code is executing.
As you learn more about the use of classes and inheritance, you'll discover that you'll benefit from their use in several ways:
The last object you're going to explore in Power Objects is the report object. An application can contain zero or more reports. To add a report to an application, open the Main Window, select the application in which you want to create the report, and press the New Report button on the toolbar. As an alternative, you can select Object | New Report from the menu. A window will appear, containing the new report. If you look at the Main Window, you will see that the new report belongs to the application (see Figure 18.17).
Page 501
Figure 18.17.
New report object
belongs to application.
If you maximize the window that contains the new report, you will see that the report contains five sections (see Figure 18.18):
ReportHeader | The objects that you place in this area will be displayed once, at the beginning of the report. |
PageHeader | The objects that you place in this band will be displayed at the top of each page. |
Detail | This band contains the objects that constitute the body of the report. These objects are repeated once for each record retrieved by the report. |
PageFooter | The objects that you place in this band will be displayed at the bottom of each page. |
ReportFooter | The objects that you place in this band will be displayed once, at the end of the report. |
Increase the width of the report by dragging the right edge of the report to the right.
Page 502
Figure 18.18.
New report layout.
Let's set some properties for the new report:
Label Course Catalog Name rptCourseCatalog RecordSource Course RecSrcSession Flugle (this is the database session to be used by the report)
Page 503
Figure 18.19. The objects in the PageHeader area will be printed at the top of each report page.
Therefore, this is where you want to specify the report title and any other information you want to
appear on every report page. Select the PageHeader by clicking on the dark gray band and
right-click Property Sheet. By default, the PageHeader has a property named
FirstPgHdr that is set to False, causing the objects in the
PageHeader to be suppressed for the first page. Set
this property to True, and close the property sheet. As shown in Figure 18.20, add a title
and subtitle for the report. Click the Static Text button on the Object Palette, and click in
the PageHeader where you want the title to appear. You will see a highlighted field labeled
static1; enter the title that you want to appear on the report. Follow the same steps to add the subtitle.
Group header and
footer bands added to
report layout.
Specifying the PageHeader Area