Customize the Inheriting Form

The appearance and behavior set by the Ancestor form provide the basic look and behavior for the inheriting form.

You can then build on this basic structure by adding other components (in this example fields and a button) to the inheriting form. You can copy the Source for the Inheriting Form (below):

Compile and execute the form:

The form now contains both inherited characteristics (the menu and status bar) and its own components and code.

When you look at the source of the inheriting form, you can see that it does not contain any DEFINE_COM statements for the components defined in the ancestor (even though they are visible in the Outline tab) nor any of the routines specified in it. The inheriting form only contains component definitions and code specific to itself.

Source for the Inheriting Form

***************************************************

*                                                 

* COMPONENT:  STD_FORM                            

*                                                 

***************************************************

FUNCTION OPTIONS(*DIRECT)

BEGIN_COM ROLE(*EXTENDS #EOEXAM01) LEFT(367) TOP(169)

* This form has ancestor EOEXAM01

*

* from which it inherits these visual characteristics:

*

*    -> A menu bar with items Open, Close and Exit on it.

*    -> A status bar showing the current user, date and time.

*

* and from which it inherits these behavioural characterstics:

*

*    -> The user, date and time on the status bar are initialized

*    -> The time on the status bar is updated every 5 seconds  

*    -> The menu bar "Exit" option is handled

*    -> Closing of the form is handled

*    -> Closing the form causes a confirmation to be displayed

*       allowing the close to be cancelled.  

*    -> The "Open" option is handled (unless redefined, see following)  

*    -> The "Close" option is handled (unless redefined)

DEFINE_COM CLASS(#EMPNO.Visual) NAME(#EMPNO) DISPLAYPOSITION(2) HEIGHT(19) LEFT(20) PARENT(#COM_OWNER) TABPOSITION(2) TOP(16) WIDTH(209)

DEFINE_COM CLASS(#SURNAME.Visual) NAME(#SURNAME) DISPLAYPOSITION(3) HEIGHT(19) LEFT(20) PARENT(#COM_OWNER) TABPOSITION(3) TOP(44) WIDTH(324)

DEFINE_COM CLASS(#GIVENAME.Visual) NAME(#GIVENAME) DISPLAYPOSITION(4) HEIGHT(19) LEFT(20) PARENT(#COM_OWNER) TABPOSITION(4) TOP(72) WIDTH(324)

DEFINE_COM CLASS(#ADDRESS1.Visual) NAME(#ADDRESS1) DISPLAYPOSITION(5) HEIGHT(19) LEFT(20) PARENT(#COM_OWNER) TABPOSITION(5) TOP(100) WIDTH(363)

DEFINE_COM CLASS(#ADDRESS2.Visual) NAME(#ADDRESS2) DISPLAYPOSITION(6) HEIGHT(19) LEFT(20) PARENT(#COM_OWNER) TABPOSITION(6) TOP(129) WIDTH(363)

DEFINE_COM CLASS(#PRIM_PHBN) NAME(#SAVE_BUTTON) CAPTION('Save') DISPLAYPOSITION(7) LEFT(392) PARENT(#COM_OWNER) TABPOSITION(7) TOP(8)

* Handle the save button ...

EVTROUTINE HANDLING(#Save_Button.Click)

Change (#Empno #Surname #GiveName #Address1 #Address2) *Default

Message 'Employee details have been saved'

ENDROUTINE

* Redefine the "HandleFileOpen" method so that this method is

* used instead of the ancestor's version of it .... 

MTHROUTINE NAME(HandleFileOpen) OPTIONS(*REDEFINE)

Use Message_Box_Show (ok Ok Info #Com_Self.Name 'Descendant HandleFileOpen method invoked') (#Std_Obj)

Endroutine

END_COM