Back to Contents


The Window class

Summary:

See also: Built-in classes, Windows and Forms, Form Class


Basics

Purpose:

The Window class is a built-in class providing an interface to the window objects.

Syntax:

ui.Window

Methods:

Class Methods
Name Description
forName( name STRING )
  
RETURNING ui.Window
Returns a Window object according to the name used in an OPEN WINDOW statement.
getCurrent( )
  
RETURNING ui.Window
Returns a Window object referencing the current window.
Object Methods
Name Description
findNode( t STRING, n STRING )
  
RETURNING om.DomNode
Returns the first descendant DOM node of type t and matching the name n in the abstract representation of this form object.
createForm( n STRING )
  
RETURNING ui.Form
Creates empty form and returns the new Form object.
getForm( )
  
RETURNING ui.Form
Returns a Form object to handle the current form.
getNode( )
  
RETURNING om.DomNode
Returns the DOM representation of this Window.
setText( t STRING ) Sets the title of this window object.
getText( )
  
RETURNING STRING
Returns the title of this window object.

Usage:

Windows are created with the OPEN WINDOW instruction, identifying the window by a static handle:

01 OPEN WINDOW w1 WITH FORM "customer"

Then you can get the corresponding object with the forName() or getCurrent() class methods. The first method returns a window object using the name of the static handle, and the second returns the object corresponding to the current window. You must declare a variable of type ui.Window to hold the window object reference:

01 DEFINE w ui.Window
02 LET w = ui.Window.forName("w1")

You can get a ui.Form instance of the current form with the getForm() method. This allows you to manipulate form elements by program. You can for example hide some parts of a form.

The getNode() method returns the DOM node containing the abstract representation of the window.

The findNode() method allows you to search for a specific DOM node in the abstract representation of the window content (i.e. the form). You search for a child node by giving its type and the name of the element (i.e. the tagname and the value of the 'name' attribute).

The createForm() method can be used to create a new empty form. The method returns a new ui.Form instance or NULL if the form name passed as parameter identifies an existing form used by the window.


Examples

Example 1: Get a window by name and change the title.

01 MAIN
02    DEFINE w ui.Window
03    OPEN WINDOW w1 WITH FORM "customer" ATTRIBUTE(TEXT="Unknown")
04    LET w = ui.Window.forName("w1")
05    IF w IS NULL THEN EXIT PROGRAM 1 END IF
06    CALL w.setText("Customer")
07    MENU "Test"
08       COMMAND "exit" EXIT MENU
09    END MENU
10    CLOSE WINDOW w1
11 END MAIN

Example 2: Get a the current form and hide a groupbox.

01 MAIN
02    DEFINE w ui.Window
03    DEFINE f ui.Form
04    OPEN WINDOW w1 WITH FORM "customer"
05    LET w = ui.Window.getCurrent()
06    IF w IS NULL THEN EXIT PROGRAM 1 END IF
07    LET f = w.getForm()
08    MENU "Test"
09       COMMAND "hide" CALL f.setElementHidden("gb1",1)
10       COMMAND "exit" EXIT MENU
11    END MENU
12    CLOSE WINDOW w1
13 END MAIN