Using inheritance to build a window  Advantages of using inheritance

Chapter 10: Working with Windows

Building two windows with similar definitions

Suppose that your application needs two windows with similar definitions. One window, w_employee, needs:

Figure 10-3 shows how the w_employee window might look.

Figure 10-3: Example window w_employee

The only differences in the second window, w_customer, are that the title is Customer Data, the drop-down list displays customer files instead of employee files, and there is a Delete button so that the user can delete files.

Your choices

To build these windows, you have three choices:

Using inheritance

To build the two windows using inheritance, follow these steps:

  1. Create an ancestor window, w_ancestor, that contains the text, drop-down list, and the open and exit buttons, and save and close it.

    NoteUsing the Window painter with inherited windows You cannot inherit a window from an existing window when the existing window is open, and you cannot open a window when its ancestor or descendant is open.

  2. Select File>Inherit, select w_ancestor in the Inherit From dialog box, and click OK.

  3. Add the Employee Data title, specify that the DropDownListBox control display employee files, and save the window as w_employee.

  4. Select File>Inherit, select w_ancestor in the Inherit From dialog box, and click OK.

  5. Add the Customer Data title, specify that the DropDownListBox control display customer files, add the Delete button, and save the window as w_customer.





Copyright © 2004. Sybase Inc. All rights reserved. Advantages of using inheritance

View this book as PDF