ParentWindow

Description

Obtains the parent window of a window.

Applies to

Window objects

Syntax

windowname.ParentWindow ( )

Argument

Description

windowname

The name of a window for which you want to obtain the parent object

Returns

Window. Returns the parent of windowname. Returns a null object reference if an error occurs or if windowname is null.

Usage

The ParentWindow function, along with the pronoun Parent, allows you to write more general scripts by avoiding the coding of actual window names. Parent refers to the window that contains the current object or control—the local environment. ParentWindow returns the parent window of a specified window.

Whether a window has a parent depends on its type and how it was opened. You can specify the parent when you open the window. For windows that always have parents, PocketBuilder chooses the parent if you do not specify it. Response windows always have a parent window.

The ParentWindow property of the Menu object can be used like a pronoun in Menu scripts. It identifies the window with which the menu is associated when your program is running. For more information, see the Users Guide.

Examples

Example 1

These statements return the parent of child_1. The parent is a window of the datatype Win1:

Win1 w_parent

w_parent = child_1.ParentWindow()

Example 2

The following script for a Cancel button in a pop-up window triggers an event for the parent window of the button’s parent window (the window that contains the button). Then it closes the button’s window. The parent window of that window will have a script for the cancelrequested event:

Parent.ParentWindow().TriggerEvent("cancelrequested")

Close(Parent)