Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Advanced PowerBuilder

HomePrevious Lesson: Using Inheritance in PowerBuilder
Next Lesson: Inheriting Menu Objects

Inheriting a Window

In the descendent window, you can do any of the following:
Override or extend the inherited events scripts.
Override and extend some events scripts.
Override/Overload object functions.
Reference the ancestor's events, functions ( as long as they aren't declared as private ).
Change attributes of controls and the content of variables.

These are the things that you can't do:
Delete any control in the descendent window, if they are painted in the ancestor.
Change the names of the inherited controls, in descendant window.

You can change the position of controls in the descendant window, but if you do so, further changes to the position of the control in the ancestor window will not be reflected in the descendant window. The same is true for changes made to any other attribute in the descendant window - It is something like overriding ancestor attribute values.

Scripts

When you select a control in the Window Painter, the Script icon displays script lines, if there is script for any event associated with that control:

This will only work if there is script for any event, associated with that particular window - the icon won't change to show the script in the ancestor window. This may become tedious when debugging an application, because you have to go into the Script Painter to determine if there is script that has been inherited from an ancestor window.

When you go into the Script Painter, there can be three versions of the standard icon, displayed beside the event names:

Icon

Description

Full Color Script

Only ancestor has the script.

Black & White Script

Only descendant has the script.

Color & BW Script

Both ancestor & descendant have script.

Viewing Ancestor Script

When you invoke the Script Painter for a descendent window, PowerBuilder doesn't display the ancestor script. For example, if you open a new window and inherit from w_about window in the example application ( PBEXAMFE.PBL ), you won't be able to see script for the open event. However, you will see a colored script icon beside the event, indicating that there is script in the ancestor window.

To see the script for the ancestor window, you have to select "Display/Display Ancestor Script...":

You are not allowed to edit an ancestor script from the descendant, but needed, you can copy and paste the script to and from the clipboard and then edit it.

Overriding Ancestor Script

If you don't want to execute the ancestor script, you can select "Design/Override Ancestor Script". When selected, the ancestor level script isn't executed - results you get from this object when this event occurs are related to the descendant level script. In cases where you don't want to execute an ancestor level script and where there is no script in the descendant window, simply add a comment in the descendant script, after selecting "Design/Override Ancestor Script". If you don't do this, PowerBuilder assumes that you still want the ancestor script to be executed and will ignore the menu selection.

Extending Ancestor Script

If both the ancestor and descendant windows have scripts, then the script for the ancestor window will be executed first, followed by the descendant window script. This is PowerBuilder's default behavior and is specified by selecting "Design/Extend Ancestor Script" from the menu in the Script Painter.

Calling Ancestor Scripts

Sometimes, you may want to execute a script for the descendant window before the ancestor script is executed. For that, follow these steps:
1 Select "Design/Override Ancestor Script".
2 Write the required script for the descendant window.
3

Call the ancestor script using the following syntax:

Call Super::<Event Name>

The Super pronoun refers to the same object in the ancestor. You can also execute an event of another control in the ancestor by using the following syntax:

Call Super'<Control Name>::<Event name>

For example, to execute the script for the OK CommandButton in our w_about window from the close event of a descendant window, we would use the following code:

Call Super'cb_ok::clicked

HomePrevious Lesson: Using Inheritance in PowerBuilder
Next Lesson: Inheriting Menu Objects

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com